Authentication
signup
Signup with devshare. If you would like to signup using an external provider (Google or Github) please see the authWithProvider
method
//Signup a new user
import { signup } from 'devshare'
signup({
username: 'testuser1',
email: '[email protected]',
password: 'testpassword'
}).then(function(signupRes){
console.log('new user signed up successfully. New user: ', signupRes.user)
}, function(err){
console.error('error signing up:', err)
})
login
Log into application. If you would like to login using an external provider (Google or Github) please see the authWithProvider
method
import { login } from 'devshare'
login('username', 'password')
.then(loginRes => console.log('logged in: ', loginRes.user)
.catch(err => console.error('error logging in:', err))
authWithProvider
Login and Signup with devshare using Google or Github
import { authWithProvider } from 'devshare'
authWithProvider('google')
.then(loginRes => console.log('authed using google: ', loginRes.user)
.catch(err => console.error('error authenticating:', err))
logout
Logout of currently logged in user
import { logout } from 'devshare'
logout()
.then(loginRes => console.log('Logged out successfully'))
getCurrentUser
Get the account for the currently logged in user
import { getCurrentUser } from 'devshare'
getCurrentUser()
.then(currentUser => console.log('Currently logged in user:', currentUser)
.catch(err => console.error('error getting current user', err))
recover
Recover user by providing username
import { recover } from 'devshare'
recover('testUser')
.then(updatedUser => console.log('Currently logged in user:', updatedUser))
.catch(err => console.error('error updating profile:', err))
uploadAvatar
Upload an image file as an avatar
import { uploadAvatar } from 'devshare'
uploadAvatar(file)
.then(imgUrl => console.log('Avatar uploaded:', imgUrl))
.catch(err => console.error('error uploading image:', err))