mirror of
https://github.com/wassname/talk.git
synced 2026-07-08 17:53:12 +08:00
Switching displayname update to account endpoint.
This commit is contained in:
@@ -15,11 +15,11 @@ export const hideCreateDisplayNameDialog = () => ({type: actions.HIDE_CREATEDISP
|
||||
const createDisplayNameSuccess = () => ({type: actions.CREATEDISPLAYNAME_SUCCESS});
|
||||
const createDisplayNameFailure = error => ({type: actions.CREATEDISPLAYNAME_FAILURE, error});
|
||||
|
||||
export const updateDisplayName = displayName => ({type: actions.UPDATE_DISPLAYNAME, displayName});
|
||||
export const updateDisplayName = ({displayName}) => ({type: actions.UPDATE_DISPLAYNAME, displayName});
|
||||
|
||||
export const createDisplayName = (userId, formData) => dispatch => {
|
||||
dispatch(createDisplayNameRequest());
|
||||
coralApi('account/displayname', {method: 'PUT', body: formData})
|
||||
coralApi('/account/displayname', {method: 'PUT', body: formData})
|
||||
.then(() => {
|
||||
dispatch(createDisplayNameSuccess());
|
||||
dispatch(hideCreateDisplayNameDialog());
|
||||
|
||||
@@ -11,6 +11,9 @@ function getQueryVariable(variable) {
|
||||
return decodeURIComponent(pair[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// If no query is included, return a default string for development
|
||||
return 'http://dev.default.stream';
|
||||
}
|
||||
|
||||
export const queryStream = graphql(STREAM_QUERY, {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Map} from 'immutable';
|
||||
import {Map, fromJS} from 'immutable';
|
||||
import * as actions from '../constants/auth';
|
||||
|
||||
const initialState = Map({
|
||||
@@ -21,7 +21,7 @@ const initialState = Map({
|
||||
|
||||
const purge = user => {
|
||||
const {settings, profiles, ...userData} = user; // eslint-disable-line
|
||||
return userData;
|
||||
return fromJS(userData);
|
||||
};
|
||||
|
||||
export default function auth (state = initialState, action) {
|
||||
@@ -131,8 +131,9 @@ export default function auth (state = initialState, action) {
|
||||
.set('passwordRequestFailure', 'There was an error sending your password reset email. Please try again soon!')
|
||||
.set('passwordRequestSuccess', null);
|
||||
case actions.UPDATE_DISPLAYNAME:
|
||||
console.log('Action', action);
|
||||
return state
|
||||
.set('user', purge(action.displayName));
|
||||
.setIn(['user', 'displayName'], action.displayName);
|
||||
case actions.EMAIL_CONFIRM_ERROR:
|
||||
return state
|
||||
.set('emailConfirmationFailure', true)
|
||||
|
||||
@@ -2,6 +2,7 @@ const express = require('express');
|
||||
const passport = require('../../../services/passport');
|
||||
const authorization = require('../../../middleware/authorization');
|
||||
const errors = require('../../../errors');
|
||||
const UsersService = require('../../../services/users');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -69,15 +70,20 @@ const HandleAuthPopupCallback = (req, res, next) => (err, user) => {
|
||||
return res.render('auth-callback', {err: JSON.stringify(errors.ErrNotAuthorized), data: null});
|
||||
}
|
||||
|
||||
// Perform the login of the user!
|
||||
req.logIn(user, (err) => {
|
||||
if (err) {
|
||||
return res.render('auth-callback', {err: JSON.stringify(err), data: null});
|
||||
}
|
||||
// Authorize the user to edit their displayName.
|
||||
UsersService.toggleNameEdit(user.id, true)
|
||||
.then(() => {
|
||||
|
||||
// Perform the login of the user!
|
||||
req.logIn(user, (err) => {
|
||||
if (err) {
|
||||
return res.render('auth-callback', {err: JSON.stringify(err), data: null});
|
||||
}
|
||||
|
||||
// We logged in the user! Let's send back the user data.
|
||||
res.render('auth-callback', {err: null, data: JSON.stringify(user)});
|
||||
});
|
||||
// We logged in the user! Let's send back the user data.
|
||||
res.render('auth-callback', {err: null, data: JSON.stringify(user)});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -645,7 +645,7 @@ module.exports = class UsersService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the user the ability to edit their username.
|
||||
* Updates the user's displayName.
|
||||
* @param {String} id the id of the user to be enabled.
|
||||
* @param {String} displayName The new displayname for the user.
|
||||
* @return {Promise}
|
||||
|
||||
Reference in New Issue
Block a user