Skip to content

Commit

Permalink
feat: create auth method for invation registration flow
Browse files Browse the repository at this point in the history
  • Loading branch information
akinsey committed Feb 3, 2022
1 parent 25e2c1c commit 2670cd5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/composables/stores/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ export default {
socketLogin(user)
}).catch(() => {})

const inviteRegistration = (username, token, email, password) => authApi.inviteRegistration({ email, username, password, confirmation: password, hash: token })
.then(dbUser => {
$appCache.set(AUTH_KEY, dbUser)
Object.assign(user, dbUser)
$prefs.fetch()
$alertStore.success(`Welcome ${user.username}, you have successfully registered!`)
socketLogin(user)
}).catch(() => {})

// Reauthenticate on app init if token is present
if (localStorageAuth().data.token) reauthenticate()

Expand All @@ -108,7 +117,8 @@ export default {
login,
logout,
register,
confirmRegistration
confirmRegistration,
inviteRegistration
})
},
render() { return this.$slots.default() } // renderless component
Expand Down

0 comments on commit 2670cd5

Please sign in to comment.