Merge pull request #15 from shocknet/gundb-auth
require logoff to reauth
This commit is contained in:
commit
838ae70aa6
1 changed files with 11 additions and 0 deletions
|
|
@ -146,6 +146,12 @@ const isRegistering = () => _isRegistering
|
|||
*/
|
||||
const authenticate = async (alias, pass) => {
|
||||
if (isAuthenticated()) {
|
||||
const currAlias = user.is && user.is.alias
|
||||
if (alias !== currAlias) {
|
||||
throw new Error(
|
||||
`Tried to re-authenticate with an alias different to that of stored one, tried: ${alias} - stored: ${currAlias}, logoff first if need to change aliases.`
|
||||
)
|
||||
}
|
||||
// move this to a subscription; implement off() ? todo
|
||||
API.Jobs.onAcceptedRequests(user, mySEA)
|
||||
return user._.sea.pub
|
||||
|
|
@ -188,6 +194,10 @@ const authenticate = async (alias, pass) => {
|
|||
}
|
||||
}
|
||||
|
||||
const logoff = () => {
|
||||
user.leave()
|
||||
}
|
||||
|
||||
const instantiateGun = async () => {
|
||||
let mySecret = ''
|
||||
|
||||
|
|
@ -934,6 +944,7 @@ const getUser = () => {
|
|||
|
||||
module.exports = {
|
||||
authenticate,
|
||||
logoff,
|
||||
createMediator,
|
||||
isAuthenticated,
|
||||
isAuthenticating,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue