cognoma / frontend

Frontend for Project Cognoma
http://cognoma.org/
Other
4 stars 22 forks source link

Angular Service creation: Application Authentication #27

Closed bdolly closed 6 years ago

bdolly commented 7 years ago

Need to create an authentication service in the front-end application logic.

@cgreene @dhimmel I've read through the core-services issue for this and am unsure what the outcome of that discussion was as far as what's to be implemented. I could use some guidance as to what the authentication process is and how it is to be implemented on the front-end.

awm33 commented 7 years ago

@bdolly When a user enters the app, or at least needs to perform an action that POSTs/PUTs, a user object needs to be created.

On the returned user object, there will be a random_slugs array field, that will always be of length 1 on creation.

POST /users

Response

{
    "id": 1,
    "name": null,
    "email": null,
    "random_slugs": ["t3fxf41sijuwxzcphuxz8r8ub"],
    "created_at": "2016-10-18T01:41:14Z",
    "updated_at": " 2016-10-18T01:41:14Z"
}

name and email are optional fields. RIght now, name could be anything, even a nickname.

The "random_slug" can be used like a token and must be added to every call that is a POST/PUT method. It is only returned on POSTs since it treated like a security token.

It is placed in the authorization header

Authorization: Bearer t3fxf41sijuwxzcphuxz8r8ub

The angular app can make this copy-pastable by placing it at the base of every angular route, like /users/t3fxf41sijuwxzcphuxz8r8ub/query or just /t3fxf41sijuwxzcphuxz8r8ub/query

The JS frontend could also store the token using a cookie or localStorage so it comes up when user just enters cognoma.org in the browser.

I don't know if you can read this python, but the tests are probably the best current examples for using the API.

random_slugs is an array so we can eventually merge users, in case someone creates two by accident, or a lab wants to merge two users worth of classifiers.

dcgoss commented 7 years ago

We have set up the backend to email the user with a link to their notebook when their classifier is processed. At the moment it doesn't seem like the user inputs their email anywhere. It would be great if the frontend could handle the user inputting their email. Let me know if you need any backend updates for this.

bdolly commented 7 years ago

@dcgoss the user email input will be part of the user/profile screen which I need wireframe and implement. Hoping to get this screen started or implemented at the next meetup