Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import authentication from 'feathers-authentication-client'
- import {feathersClient} from './index'
- feathersClient.configure(authentication({ storage: window.localStorage }))
- const authenticate = async (email=null, password=null) => {
- try {
- let response
- if(email && password) {
- response = await feathersClient.authenticate({
- strategy: 'local',
- email,
- password
- })
- } else {
- response = await feathersClient.authenticate()
- }
- const payload = await feathersClient.passport.verifyJWT(response.accessToken)
- const user = await feathersClient.service('users').get(payload.userId)
- feathersClient.set('user', user)
- console.log(user)
- return feathersClient.get('user')
- }
- catch(error) {
- throw error
- }
- }
- const logout = () => {
- return feathersClient.logout()
- }
- export {
- authenticate,
- logout
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement