File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { authHeader } from '../_helpers';
33
44export const userService = {
55 login,
6+ loginWithState,
67 logout,
78 getAll
89} ;
@@ -24,6 +25,22 @@ function login(username, password) {
2425 } ) ;
2526}
2627
28+ function loginWithState ( state ) {
29+ const requestOptions = {
30+ method : 'POST' ,
31+ headers : { 'Content-Type' : 'application/json' } ,
32+ body : JSON . stringify ( { state } )
33+ } ;
34+ return fetch ( `${ config . apiUrl } /users/stateauth` , requestOptions )
35+ . then ( handleResponse )
36+ . then ( user => {
37+ // store user details and jwt token in local storage to keep user logged in between page refreshes
38+ localStorage . setItem ( 'user' , JSON . stringify ( user ) ) ;
39+
40+ return user ;
41+ } ) ;
42+ }
43+
2744function logout ( ) {
2845 // remove user from local storage to log user out
2946 localStorage . removeItem ( 'user' ) ;
You can’t perform that action at this time.
0 commit comments