修复密码修改bug
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MainController struct {
|
type MainController struct {
|
||||||
@@ -117,29 +118,21 @@ func (this *MainController) Profile() {
|
|||||||
user, _ := models.UserGetById(this.userId)
|
user, _ := models.UserGetById(this.userId)
|
||||||
|
|
||||||
if this.isPost() {
|
if this.isPost() {
|
||||||
flash := beego.NewFlash()
|
|
||||||
user.Email = this.GetString("email")
|
user.Email = this.GetString("email")
|
||||||
user.Update()
|
user.Update()
|
||||||
password1 := this.GetString("password1")
|
password1 := this.GetString("password1")
|
||||||
password2 := this.GetString("password2")
|
password2 := this.GetString("password2")
|
||||||
if password1 != "" {
|
if password1 != "" {
|
||||||
if len(password1) < 6 {
|
if len(password1) < 6 {
|
||||||
flash.Error("密码长度必须大于6位")
|
this.ajaxMsg("密码长度必须大于6位", MSG_ERR)
|
||||||
flash.Store(&this.Controller)
|
|
||||||
this.redirect(beego.URLFor(".Profile"))
|
|
||||||
} else if password2 != password1 {
|
} else if password2 != password1 {
|
||||||
flash.Error("两次输入的密码不一致")
|
this.ajaxMsg("两次输入的密码不一致", MSG_ERR)
|
||||||
flash.Store(&this.Controller)
|
|
||||||
this.redirect(beego.URLFor(".Profile"))
|
|
||||||
} else {
|
} else {
|
||||||
user.Salt = string(utils.RandomCreateBytes(10))
|
user.Salt = string(utils.RandomCreateBytes(10))
|
||||||
user.Password = libs.Md5([]byte(password1 + user.Salt))
|
user.Password = libs.Md5([]byte(password1 + user.Salt))
|
||||||
user.Update()
|
user.Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// flash.Success("修改成功!")
|
|
||||||
// flash.Store(&this.Controller)
|
|
||||||
// this.redirect(beego.URLFor(".Profile"))
|
|
||||||
this.ajaxMsg("", MSG_OK)
|
this.ajaxMsg("", MSG_OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,9 @@
|
|||||||
{{range $k, $v := .recentLogs}}
|
{{range $k, $v := .recentLogs}}
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="w45 pull-left">
|
<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>
|
||||||
<div class="w45 pull-left">{{$v.start_time}} </div>
|
<div class="w45 pull-left">{{$v.start_time}} </div>
|
||||||
<div class="w10 pull-left">
|
<div class="w10 pull-left">
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
密码修改
|
|
||||||
@@ -40,9 +40,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" style="margin-top: 15px">
|
<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" >
|
<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>
|
||||||
<div class="col-sm-6" style="padding-top:5px;">
|
<div class="col-sm-6" style="padding-top:5px;">
|
||||||
<i>不修改密码请留空</i>
|
<i>不修改密码请留空</i>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" style="margin-top: 15px">
|
<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" >
|
<div class="col-sm-3" >
|
||||||
<input type="text" class="form-control input-sm" placeholder="" name="password2" value="" />
|
<input type="text" class="form-control input-sm" placeholder="" name="password2" value="" />
|
||||||
</div>
|
</div>
|
||||||
@@ -73,8 +73,8 @@
|
|||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
$("form").submit(function () {
|
$("form").submit(function () {
|
||||||
|
// console.log($(this).serialize());
|
||||||
$("button[type='submit']").attr('disabled', true);
|
//$("button[type='submit']").attr('disabled', true);
|
||||||
$.post('{{urlfor "MainController.Profile"}}', $(this).serialize(), function (out) {
|
$.post('{{urlfor "MainController.Profile"}}', $(this).serialize(), function (out) {
|
||||||
if (out.status == 0) {
|
if (out.status == 0) {
|
||||||
alert("保存成功");
|
alert("保存成功");
|
||||||
|
|||||||
Reference in New Issue
Block a user