aboutsummaryrefslogtreecommitdiff
path: root/src/modules/users.js
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2024-07-31 16:31:06 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2024-07-31 16:31:06 +0000
commit6bc020c733047d7033e508a2b4dffc581d703170 (patch)
treefe52d41d57c827e8872da21e5ac10d412058f43e /src/modules/users.js
parent83acbf953a4f50a017e3e857ecbd0b008f0b3be0 (diff)
parent9d51eccf5dd0b4b773db5ec146d818b6c8fe18ac (diff)
Merge branch 'release/2.7.x' into 'master'
Release 2.7.0 See merge request pleroma/pleroma-fe!1928
Diffstat (limited to 'src/modules/users.js')
-rw-r--r--src/modules/users.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/modules/users.js b/src/modules/users.js
index 50b4cb84..b8f49f15 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -2,7 +2,7 @@ import backendInteractorService from '../services/backend_interactor_service/bac
import { windowWidth, windowHeight } from '../services/window_utils/window_utils'
import oauthApi from '../services/new_api/oauth.js'
import { compact, map, each, mergeWith, last, concat, uniq, isArray } from 'lodash'
-import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'
+import { registerPushNotifications, unregisterPushNotifications } from '../services/sw/sw.js'
// TODO: Unify with mergeOrAdd in statuses.js
export const mergeOrAdd = (arr, obj, item) => {
@@ -250,6 +250,7 @@ export const mutations = {
signUpPending (state) {
state.signUpPending = true
state.signUpErrors = []
+ state.signUpNotice = {}
},
signUpSuccess (state) {
state.signUpPending = false
@@ -257,6 +258,12 @@ export const mutations = {
signUpFailure (state, errors) {
state.signUpPending = false
state.signUpErrors = errors
+ state.signUpNotice = {}
+ },
+ signUpNotice (state, notice) {
+ state.signUpPending = false
+ state.signUpErrors = []
+ state.signUpNotice = notice
}
}
@@ -287,6 +294,7 @@ export const defaultState = {
usersByNameObject: {},
signUpPending: false,
signUpErrors: [],
+ signUpNotice: {},
relationships: {}
}
@@ -498,7 +506,7 @@ const users = {
store.commit('addNewUsers', users)
store.commit('addNewUsers', targetUsers)
- const notificationsObject = store.rootState.statuses.notifications.idStore
+ const notificationsObject = store.rootState.notifications.idStore
const relevantNotifications = Object.entries(notificationsObject)
.filter(([k, val]) => notificationIds.includes(k))
.map(([k, val]) => val)
@@ -524,9 +532,16 @@ const users = {
const data = await rootState.api.backendInteractor.register(
{ params: { ...userInfo } }
)
- store.commit('signUpSuccess')
- store.commit('setToken', data.access_token)
- store.dispatch('loginUser', data.access_token)
+
+ if (data.access_token) {
+ store.commit('signUpSuccess')
+ store.commit('setToken', data.access_token)
+ store.dispatch('loginUser', data.access_token)
+ return 'ok'
+ } else { // Request succeeded, but user cannot login yet.
+ store.commit('signUpNotice', data)
+ return 'request_sent'
+ }
} catch (e) {
const errors = e.message
store.commit('signUpFailure', errors)
@@ -667,7 +682,7 @@ const users = {
resolve()
})
.catch((error) => {
- console.log(error)
+ console.error(error)
commit('endLogin')
reject(new Error('Failed to connect to server, try again'))
})