Skip to content

Commit c2d9ef7

Browse files
Anthony KinseyAnthony Kinsey
Anthony Kinsey
authored and
Anthony Kinsey
committed
feat: create auth method for confirming registration
1 parent 4fb401e commit c2d9ef7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/composables/stores/auth.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,16 @@ export default {
8484
$alertStore.success(`Welcome ${user.username}, you have successfully registered!`)
8585
socketLogin(user)
8686
}
87-
else return true
88-
// TODO(akinsey): implement flow for when email confirmation is enabled
89-
// else {}
87+
else return true // when email confirmation is enabled, tell modal to show confirmation msg
88+
}).catch(() => {})
89+
90+
const confirmRegistration = (username, token) => authApi.confirmRegistration({ username, token })
91+
.then(dbUser => {
92+
$appCache.set(AUTH_KEY, dbUser)
93+
Object.assign(user, dbUser)
94+
$prefs.fetch()
95+
$alertStore.success(`Welcome ${user.username}, you have successfully registered!`)
96+
socketLogin(user)
9097
}).catch(() => {})
9198

9299
// Reauthenticate on app init if token is present
@@ -100,7 +107,8 @@ export default {
100107
reauthenticate,
101108
login,
102109
logout,
103-
register
110+
register,
111+
confirmRegistration
104112
})
105113
},
106114
render() { return this.$slots.default() } // renderless component

0 commit comments

Comments
 (0)