From 2670cd5c62e8eeb551279409ce92c0b0762c6666 Mon Sep 17 00:00:00 2001 From: Anthony Kinsey Date: Thu, 3 Feb 2022 12:02:02 -1000 Subject: [PATCH] feat: create auth method for invation registration flow --- src/composables/stores/auth.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/composables/stores/auth.js b/src/composables/stores/auth.js index 5e9ecbbb..ae780e35 100644 --- a/src/composables/stores/auth.js +++ b/src/composables/stores/auth.js @@ -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() @@ -108,7 +117,8 @@ export default { login, logout, register, - confirmRegistration + confirmRegistration, + inviteRegistration }) }, render() { return this.$slots.default() } // renderless component