修复密码修改bug

This commit is contained in:
郝大全
2017-07-05 10:56:00 +08:00
parent 1e4b9b31e3
commit 249f1beed7
4 changed files with 11 additions and 17 deletions

View File

@@ -16,6 +16,7 @@ import (
"strconv"
"strings"
"time"
"fmt"
)
type MainController struct {
@@ -117,29 +118,21 @@ func (this *MainController) Profile() {
user, _ := models.UserGetById(this.userId)
if this.isPost() {
flash := beego.NewFlash()
user.Email = this.GetString("email")
user.Update()
password1 := this.GetString("password1")
password2 := this.GetString("password2")
if password1 != "" {
if len(password1) < 6 {
flash.Error("密码长度必须大于6位")
flash.Store(&this.Controller)
this.redirect(beego.URLFor(".Profile"))
this.ajaxMsg("密码长度必须大于6位", MSG_ERR)
} else if password2 != password1 {
flash.Error("两次输入的密码不一致")
flash.Store(&this.Controller)
this.redirect(beego.URLFor(".Profile"))
this.ajaxMsg("两次输入的密码不一致", MSG_ERR)
} else {
user.Salt = string(utils.RandomCreateBytes(10))
user.Password = libs.Md5([]byte(password1 + user.Salt))
user.Update()
}
}
// flash.Success("修改成功!")
// flash.Store(&this.Controller)
// this.redirect(beego.URLFor(".Profile"))
this.ajaxMsg("", MSG_OK)
}

View File

@@ -90,7 +90,9 @@
{{range $k, $v := .recentLogs}}
<div class="panel-body">
<div class="w45 pull-left">
<a href="{{urlfor "TaskController.ViewLog" "id" $v.id}}" class="news-item-title">{{$v.task_name}} # {{$v.id}}</a>
<a href="{{urlfor "TaskController.ViewLog" "id" $v.id}}" class="news-item-title">
{{$v.task_name}} # {{$v.id}}
</a>
</div>
<div class="w45 pull-left">{{$v.start_time}} </div>
<div class="w10 pull-left">

View File

@@ -1 +0,0 @@
密码修改

View File

@@ -40,9 +40,9 @@
</div>
<div class="form-group" style="margin-top: 15px">
<label class="col-sm-3 control-label" for="password">新密码</label>
<label class="col-sm-3 control-label" for="password1">新密码</label>
<div class="col-sm-3" >
<input type="text" class="form-control input-sm" placeholder="" name="password" value="" />
<input type="text" class="form-control input-sm" placeholder="" name="password1" value="" />
</div>
<div class="col-sm-6" style="padding-top:5px;">
<i>不修改密码请留空</i>
@@ -50,7 +50,7 @@
</div>
<div class="form-group" style="margin-top: 15px">
<label class="col-sm-3 control-label" for="concurrent">确认密码</label>
<label class="col-sm-3 control-label" for="password2">确认密码</label>
<div class="col-sm-3" >
<input type="text" class="form-control input-sm" placeholder="" name="password2" value="" />
</div>
@@ -73,8 +73,8 @@
<script>
$(function () {
$("form").submit(function () {
$("button[type='submit']").attr('disabled', true);
// console.log($(this).serialize());
//$("button[type='submit']").attr('disabled', true);
$.post('{{urlfor "MainController.Profile"}}', $(this).serialize(), function (out) {
if (out.status == 0) {
alert("保存成功");