feat(users): use displayName alternative first name and last name

This commit is contained in:
OldHawk
2017-11-09 16:36:40 +08:00
parent 8de65c386c
commit 22343353bd
12 changed files with 24 additions and 65 deletions

View File

@@ -221,8 +221,7 @@
PASSWORD_REQ: 'Password Requirements',
P_REQUIRED: 'Password is required.',
FORGOT_PASSWORD: 'Forgot your password?',
FN_REQUIRED: 'First name is required.',
LN_REQUIRED: 'Last name is required.',
DN_REQUIRED: 'Display name is required.',
NEW_PASSWORD: 'New Password',
NP_REQUIRED: 'Enter a new password.',
@@ -614,8 +613,6 @@
RESET_DEFAULT_PICTURE: 'Reset to default picture',
ADD_VIP_MONTHS: '+ VIP a month',
USERNAME: 'Username',
FIRST_NAME: 'First name',
LAST_NAME: 'Last name',
DISPLAY_NAME: 'Display name',
INVITED_BY: 'Invited by',
EMAIL: 'Email',

View File

@@ -221,8 +221,7 @@
PASSWORD_REQ: '密码强度检测',
P_REQUIRED: '密码不能为空.',
FORGOT_PASSWORD: '忘记了密码?',
FN_REQUIRED: '姓氏不能为空.',
LN_REQUIRED: '名字不能为空.',
DN_REQUIRED: '显示昵称不能为空.',
NEW_PASSWORD: '新密码',
NP_REQUIRED: '新密码不能为空.',
@@ -614,8 +613,6 @@
RESET_DEFAULT_PICTURE: '重置为默认图片',
ADD_VIP_MONTHS: '+ VIP一个月',
USERNAME: '用户名',
FIRST_NAME: '姓',
LAST_NAME: '名',
DISPLAY_NAME: '显示昵称',
INVITED_BY: '邀请发送人',
EMAIL: '邮箱',

View File

@@ -87,6 +87,7 @@
return false;
}
vm.user.lastName = '';
var user = vm.user;
user.$update(function () {

View File

@@ -29,6 +29,11 @@
Notification.error({message: $location.search().err});
}
// If user is signed in then redirect back home
if (vm.authentication.user && !vm.activeMethod) {
$location.path('/');
}
/**
* account active successfully, redirect to home after 2 seconds
*/
@@ -72,6 +77,7 @@
vm.credentials.inviteToken = $stateParams.token;
}
vm.credentials.lastName = '';
UsersService.userSignup(vm.credentials)
.then(onUserSignupSuccess)
.catch(onUserSignupError);
@@ -109,7 +115,7 @@
vm.authentication.user = response;
$rootScope.$broadcast('auth-user-changed');
$rootScope.$broadcast('user-invitations-changed');
Notification.info({message: 'Welcome ' + response.firstName});
Notification.info({message: 'Welcome ' + response.displayName});
// And redirect to the previous or home page
$state.go($state.previous.state.name || 'home', $state.previous.params);
}

View File

@@ -22,15 +22,16 @@
return false;
}
vm.user.lastName = '';
var user = new UsersService(vm.user);
user.$update(function (response) {
$scope.$broadcast('show-errors-reset', 'vm.userForm');
Notification.success({ message: '<i class="glyphicon glyphicon-ok"></i> Edit profile successful!' });
Notification.success({message: '<i class="glyphicon glyphicon-ok"></i> Edit profile successful!'});
Authentication.user = response;
}, function (response) {
Notification.error({ message: response.data.message, title: '<i class="glyphicon glyphicon-remove"></i> Edit profile failed!' });
Notification.error({message: response.data.message, title: '<i class="glyphicon glyphicon-remove"></i> Edit profile failed!'});
});
}
}

View File

@@ -6,17 +6,10 @@
<form name="vm.userForm" ng-submit="vm.update(vm.userForm.$valid)" novalidate>
<fieldset>
<div class="form-group" show-errors>
<label for="firstName">First Name</label>
<input type="text" id="firstName" name="firstName" class="form-control" ng-model="vm.user.firstName" placeholder="First Name" required autofocus />
<label for="firstName">{{ 'STATUS_FIELD.DISPLAY_NAME' | translate}}</label>
<input type="text" id="firstName" name="firstName" class="form-control" ng-model="vm.user.firstName" placeholder="{{ 'STATUS_FIELD.DISPLAY_NAME' | translate}}" required autofocus />
<div ng-messages="vm.userForm.firstName.$error" role="alert">
<p class="help-block error-text" ng-message="required">First name is required.</p>
</div>
</div>
<div class="form-group" show-errors>
<label for="lastName">Last Name</label>
<input type="text" id="lastName" name="lastName" class="form-control" ng-model="vm.user.lastName" placeholder="Last Name" required />
<div ng-messages="vm.userForm.lastName.$error" role="alert">
<p class="help-block error-text" ng-message="required">Last name is required.</p>
<p class="help-block error-text" ng-message="required">{{ 'STATUS_FIELD.DN_REQUIRED' | translate}}</p>
</div>
</div>
<div class="form-group" show-errors>

View File

@@ -34,12 +34,6 @@
<dt class="h-line">{{ 'STATUS_FIELD.USERNAME' | translate}}</dt>
<dd class="h-line">{{ vm.user.username }}</dd>
<!--<dt class="h-line">{{ 'STATUS_FIELD.FIRST_NAME' | translate}}</dt>-->
<!--<dd class="h-line">{{ vm.user.firstName }}</dd>-->
<!--<dt class="h-line">{{ 'STATUS_FIELD.LAST_NAME' | translate}}</dt>-->
<!--<dd class="h-line">{{ vm.user.lastName }}</dd>-->
<dt class="h-line">{{ 'STATUS_FIELD.DISPLAY_NAME' | translate}}</dt>
<dd class="h-line">
{{ vm.user.displayName }}

View File

@@ -12,18 +12,10 @@
<fieldset>
<div class="form-group" show-errors>
<input type="text" id="firstName" name="firstName" class="form-control" ng-model="vm.credentials.firstName"
placeholder="{{ 'STATUS_FIELD.FIRST_NAME' | translate}}" required autofocus>
placeholder="{{ 'STATUS_FIELD.DISPLAY_NAME' | translate}}" required autofocus>
<div ng-messages="vm.userForm.firstName.$error" role="alert">
<p class="help-block error-text" ng-message="required">{{ 'SIGN.FN_REQUIRED' | translate}}</p>
</div>
</div>
<div class="form-group" show-errors>
<input type="text" id="lastName" name="lastName" class="form-control" ng-model="vm.credentials.lastName"
placeholder="{{ 'STATUS_FIELD.LAST_NAME' | translate}}" required>
<div ng-messages="vm.userForm.lastName.$error" role="alert">
<p class="help-block error-text" ng-message="required">{{ 'SIGN.LN_REQUIRED' | translate}}</p>
<p class="help-block error-text" ng-message="required">{{ 'SIGN.DN_REQUIRED' | translate}}</p>
</div>
</div>
<div class="form-group" show-errors>

View File

@@ -3,23 +3,13 @@
<form name="vm.userForm" ng-submit="vm.updateUserProfile(vm.userForm.$valid)" class="signin" novalidate autocomplete="off">
<fieldset>
<div class="form-group" show-errors>
<label for="firstName">{{ 'STATUS_FIELD.FIRST_NAME' | translate}}</label>
<label for="firstName">{{ 'STATUS_FIELD.DISPLAY_NAME' | translate}}</label>
<input type="text" id="firstName" name="firstName" class="form-control" ng-model="vm.user.firstName"
placeholder="{{ 'STATUS_FIELD.FIRST_NAME' | translate}}"
placeholder="{{ 'STATUS_FIELD.DISPLAY_NAME' | translate}}"
required autofocus>
<div ng-messages="vm.userForm.firstName.$error" role="alert">
<p class="help-block error-text" ng-message="required">{{ 'SIGN.FN_REQUIRED' | translate}}</p>
</div>
</div>
<div class="form-group" show-errors>
<label for="lastName">{{ 'STATUS_FIELD.LAST_NAME' | translate}}</label>
<input type="text" id="lastName" name="lastName" class="form-control" ng-model="vm.user.lastName"
placeholder="{{ 'STATUS_FIELD.LAST_NAME' | translate}}"
required>
<div ng-messages="vm.userForm.lastName.$error" role="alert">
<p class="help-block error-text" ng-message="required">{{ 'SIGN.LN_REQUIRED' | translate}}</p>
<p class="help-block error-text" ng-message="required">{{ 'SIGN.DN_REQUIRED' | translate}}</p>
</div>
</div>
<div class="form-group" show-errors>

View File

@@ -21,12 +21,6 @@
<dt class="h-line">{{ 'STATUS_FIELD.USERNAME' | translate}}</dt>
<dd class="h-line">{{ vm.user.username }}</dd>
<!--<dt class="h-line">{{ 'STATUS_FIELD.FIRST_NAME' | translate}}</dt>-->
<!--<dd class="h-line">{{ vm.user.firstName }}</dd>-->
<!--<dt class="h-line">{{ 'STATUS_FIELD.LAST_NAME' | translate}}</dt>-->
<!--<dd class="h-line">{{ vm.user.lastName }}</dd>-->
<dt class="h-line">{{ 'STATUS_FIELD.DISPLAY_NAME' | translate}}</dt>
<dd class="h-line">
{{ vm.user.displayName }}

View File

@@ -27,12 +27,6 @@
<dt class="h-line">{{ 'STATUS_FIELD.USERNAME' | translate}}</dt>
<dd class="h-line">{{ vm.user.username }}</dd>
<!--<dt class="h-line">{{ 'STATUS_FIELD.FIRST_NAME' | translate}}</dt>-->
<!--<dd class="h-line">{{ vm.user.firstName }}</dd>-->
<!--<dt class="h-line">{{ 'STATUS_FIELD.LAST_NAME' | translate}}</dt>-->
<!--<dd class="h-line">{{ vm.user.lastName }}</dd>-->
<dt class="h-line">{{ 'STATUS_FIELD.DISPLAY_NAME' | translate}}</dt>
<dd class="h-line">
{{ vm.user.displayName }}

View File

@@ -57,13 +57,13 @@ var UserSchema = new Schema({
type: String,
trim: true,
default: '',
validate: [validateLocalStrategyProperty, 'Please fill in your first name']
validate: [validateLocalStrategyProperty, 'Please fill in your display name']
},
lastName: {
type: String,
trim: true,
default: '',
validate: [validateLocalStrategyProperty, 'Please fill in your last name']
default: ''
//validate: [validateLocalStrategyProperty, 'Please fill in your last name']
},
displayName: {
type: String,