修改个人信息中的邮箱去除
This commit is contained in:
parent
34b14b4e51
commit
5074d61dba
|
@ -283,7 +283,6 @@ module Mobile
|
|||
requires :token, type: String
|
||||
requires :lastname, type: String
|
||||
requires :sex, type: Integer
|
||||
requires :mail, type: String
|
||||
end
|
||||
|
||||
post 'edit_userinfo' do
|
||||
|
@ -298,41 +297,11 @@ module Mobile
|
|||
status = -1
|
||||
end
|
||||
|
||||
if params[:mail].length > 60 then
|
||||
message = "邮箱地址不能超过60个字符!"
|
||||
status = -1
|
||||
end
|
||||
|
||||
if !(params[:mail].match(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i))
|
||||
message = "请输入正确的邮箱地址!"
|
||||
status = -1
|
||||
end
|
||||
|
||||
if status == 0
|
||||
# 修改邮箱的时候同步修改到gitlab
|
||||
if user.mail != params[:mail]
|
||||
g = Gitlab.client
|
||||
begin
|
||||
g.edit_user(user.gid, :email => params[:mail])
|
||||
rescue
|
||||
Rails.logger.error "sync user's email of gitlab failed!"
|
||||
end
|
||||
end
|
||||
|
||||
user.mail = params[:mail]
|
||||
|
||||
user.lastname = params[:lastname]
|
||||
|
||||
user.update_attribute(:lastname, params[:lastname])
|
||||
se = user.extensions
|
||||
|
||||
se.gender = params[:sex]
|
||||
|
||||
if user.save && se.save
|
||||
status = 0
|
||||
else
|
||||
message = "该邮箱地址已被使用!"
|
||||
status = -1
|
||||
end
|
||||
se.update_attribute(:gender, params[:sex])
|
||||
end
|
||||
|
||||
if status == 0
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="course-list-row f13 c-grey3 mt10">
|
||||
<span class="fl ml15 c-grey3">邮箱</span>
|
||||
<input class="new-class-input ml25" type="email" name="email" ng-model="mail" placeholder="请输入您的邮箱地址" maxlength="60" />
|
||||
</div>
|
||||
<!--<div class="course-list-row f13 c-grey3 mt10">-->
|
||||
<!--<span class="fl ml15 c-grey3">邮箱</span>-->
|
||||
<!--<input class="new-class-input ml25" type="email" name="email" ng-model="mail" maxlength="60" disabled />-->
|
||||
<!--</div>-->
|
||||
<div ng-show="regFrm.$submitted || regFrm.email.$touched">
|
||||
<span class="f12 c-red ml65" ng-show="regFrm.email.$error.required">电子邮箱地址不能为空</span>
|
||||
<span class="f12 c-red ml65" ng-show="regFrm.email.$error.email">电子邮箱地址不合法</span>
|
||||
|
|
|
@ -64,18 +64,13 @@ app.controller('EditUserInfoController', ['$scope', 'config','$http', 'auth','$l
|
|||
return;
|
||||
}
|
||||
|
||||
if(vm.mail == ""){
|
||||
vm.alertService_1.showMessage('提示', '邮箱不能为空');
|
||||
return;
|
||||
}
|
||||
|
||||
// if(!(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.test(vm.mail))){
|
||||
// vm.alertService_1.showMessage('提示', '邮箱不合法');
|
||||
// return;
|
||||
// }
|
||||
|
||||
$http.post(config.apiUrl + "users/edit_userinfo",
|
||||
{token: auth.token(),lastname: vm.lastname, sex: vm.sex, mail: vm.mail}
|
||||
{token: auth.token(),lastname: vm.lastname, sex: vm.sex}
|
||||
).then(function(response){
|
||||
if(response.data.status == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue