@xanthous/auth
v0.3.4
Published
## Instalation
Downloads
16
Keywords
Readme
Auth Module
Instalation
yarn add @xanthous/auth
Backend
for dublicate default providers.js
cp node_modules/@xanthous/auth/providers.js /path/to/backend
and add this to directory into your server/model-config.json
"_meta": {
"sources": [
"../node_modules/@xanthous/auth/build/models",
"../node_modules/@xanthous/auth/node_modules/loopback-component-passport/lib/models",
],
"mixins": [
]
},
and add this in models
"user": {
"dataSource": "db",
"public": true
},
"accessToken": {
"dataSource": "db",
"public": false
},
"userCredential": {
"dataSource": "db",
"public": false
},
"userIdentity": {
"dataSource": "db",
"public": false
},
add this to server/server.js
const { configurator: authConfigurator } = require('@xanthous/auth');
/*
...
..
.
after boot script
*/
authConfigurator(app, {
providersConfig: require('./auth-providers'),
sessionSecret: 'XXXXX',
});
if you don't want to use default userIdentity
, userCredentia
and access-token
cp -r node_modules/@xanthous/auth/models/* path/to/backend/common/models/
FrontEnd
add to reducers.js
import auth from '@xanthous/auth/build/reducer'
export default combineReducers({
auth,
...
...
});
when you wanna use the functions
import { login } from '@xanthous/auth/build/reducer'
function mapDispatchToProps(dispatch) {
return {
login: (credentials) => dispatch(login(credentials))
};
}
Avaible methods.
signup
login
loginWithFacebook
loginWithGoogle
logout