Skip to content

Commit 6a298e1

Browse files
committed
可以正常修改密码了
1 parent 78a4e25 commit 6a298e1

9 files changed

Lines changed: 94 additions & 4 deletions

File tree

apis/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func password(ctx *gin.Context) {
156156
return
157157
}
158158

159-
pwd.Password = md5hash(obj.New)
159+
pwd.Password = obj.New
160160
_, err = db.Engine().ID(ctx.GetString("user")).Cols("password").Update(&pwd)
161161
if err != nil {
162162
api.Error(ctx, err)

dist/browser/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
<style>html,body{height:auto!important;width:auto!important;overflow:auto}</style><link rel="stylesheet" href="styles-3KASNK4X.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles-3KASNK4X.css"></noscript></head>
1111
<body>
1212
<app-root></app-root>
13-
<link rel="modulepreload" href="chunk-WDQJDPUK.js"><link rel="modulepreload" href="chunk-ZBPQ26PG.js"><link rel="modulepreload" href="chunk-5GQ5K75U.js"><script src="polyfills-DOYHMSTV.js" type="module"></script><script src="main-74WRFY4B.js" type="module"></script></body>
13+
<link rel="modulepreload" href="chunk-WDQJDPUK.js"><link rel="modulepreload" href="chunk-ZBPQ26PG.js"><link rel="modulepreload" href="chunk-5GQ5K75U.js"><script src="polyfills-DOYHMSTV.js" type="module"></script><script src="main-Q5GCHVGT.js" type="module"></script></body>
1414
</html>

dist/browser/main-74WRFY4B.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/browser/main-Q5GCHVGT.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/admin/admin.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ <h1>{{ oem.name }}</h1>
4747
<nz-dropdown-menu #user>
4848
<ul nz-menu>
4949
<li nz-menu-item>个人中心</li>
50-
<li nz-menu-item>修改密码</li>
50+
<li nz-menu-item>
51+
<a routerLink="/password">修改密码</a>
52+
</li>
5153
<li nz-menu-divider></li>
5254
<li nz-menu-item (click)="logout()">退出</li>
5355
</ul>

src/app/app.routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {UnknownComponent} from './unknown/unknown.component';
66
import {PageComponent} from './page/page.component';
77
import {SettingComponent} from './setting/setting.component';
88
import {AdminComponent} from './admin/admin.component';
9+
import {PasswordComponent} from './password/password';
910

1011
export const adminRoutes: Routes = [
1112
//{path: '', pathMatch: 'full', redirectTo: ''},
1213
{path: 'login', component: LoginComponent},
14+
{path: 'password', component: PasswordComponent},
1315
{
1416
path: '',
1517
canActivate: [loginGuard],

src/app/password/password.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="login">
2+
3+
<nz-card nzTitle="修改密码">
4+
5+
<smart-editor #editor [fields]="fields" (submit)="submit()"></smart-editor>
6+
7+
<div style="float: right">
8+
<button nz-button nzType="primary" (click)="submit()">提 交</button>
9+
</div>
10+
</nz-card>
11+
</div>
12+

src/app/password/password.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
:host {
2+
width: 100vw;
3+
height: 100vh;
4+
display: flex;
5+
flex-direction: row;
6+
align-items: center;
7+
justify-content: center;
8+
background: #00152a;
9+
}
10+
11+
.login {
12+
width: 400px;
13+
//box-shadow: #001529 5px 3px 3px;
14+
}

src/app/password/password.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import {Component, ViewChild} from '@angular/core';
2+
import {SmartEditorComponent, SmartField} from '../lib/smart-editor/smart-editor.component';
3+
import {Router} from '@angular/router';
4+
import {NzNotificationService} from 'ng-zorro-antd/notification';
5+
import {SmartRequestService} from '../lib/smart-request.service';
6+
import {UserService} from '../user.service';
7+
import {Md5} from 'ts-md5';
8+
import {NzCardComponent} from 'ng-zorro-antd/card';
9+
import {NzButtonComponent} from 'ng-zorro-antd/button';
10+
11+
@Component({
12+
selector: 'app-password',
13+
standalone: true,
14+
imports: [
15+
SmartEditorComponent,
16+
NzCardComponent,
17+
NzButtonComponent
18+
],
19+
templateUrl: './password.html',
20+
styleUrl: './password.scss',
21+
})
22+
export class PasswordComponent {
23+
24+
fields: SmartField[] = [
25+
{key: 'old', type: 'password', label: '旧密码', required: true},
26+
{key: 'new', type: 'password', label: '新密码', required: true},
27+
]
28+
29+
@ViewChild("editor", {static: true}) editor!: SmartEditorComponent;
30+
31+
constructor(private router: Router,
32+
private ns: NzNotificationService,
33+
private request: SmartRequestService,
34+
private us: UserService,
35+
) {
36+
}
37+
38+
submit() {
39+
40+
if (!this.editor.valid) {
41+
this.ns.error("错误", "无效密码")
42+
return
43+
}
44+
45+
let obj = this.editor.value
46+
this.request.post("password", {
47+
old: Md5.hashStr(obj.old),
48+
new: Md5.hashStr(obj.new),
49+
}).subscribe(res => {
50+
console.log("password", res)
51+
if (res.error) {
52+
return
53+
}
54+
this.ns.success("提示", "修改成功,请重新登录")
55+
56+
localStorage.removeItem("token")
57+
this.router.navigateByUrl('/login')
58+
})
59+
}
60+
}

0 commit comments

Comments
 (0)