LCOGT / lco-education-platform

LCO's education platform for students and teachers
0 stars 0 forks source link

Feature/login functionality #52

Closed capetillo closed 5 months ago

capetillo commented 5 months ago

FEATURE: Log in functionality

Background: In order to be able create a realtime block, we need to have an authorization token. This can be obtained by logging in through the observation portal api.

*Implementation:** Though not styled, the functionality is there. I added a userData store to store the auth token and the user's profile. I also created the same api.js file from datalab to reuse the fetchApiCall. Then the logic in LogIn is first, the username and password are sent as the body for the api call to https://observe.lco.global/api/api-token-auth. The success callback is storeToken which stores the token in the store and makes a GET request to https://observe.lco.global/api/profile/ to get the user. The success callback of this is storeUser, which stores the user in the userData store.

NOTE FOR NEAR FUTURE: I have to add error handling. Right now it's only in the console

VISUALS

Screen recording of successfully logging in

https://github.com/LCOGT/lco-education-platform/assets/54489472/5c548a27-9d3b-4de6-8239-77a7c06d0f61

screen recording of not successful login

https://github.com/LCOGT/lco-education-platform/assets/54489472/f1559f21-4d09-4df9-a278-b9efe97fad5a