Browse Source

[新增]增加免登录

guangxi
邵佳豪 9 months ago
parent
commit
8a6349b446
  1. 2
      proxy.config.json
  2. 2
      src/app/pages/lockscreen/lockscreen.component.html
  3. 36
      src/app/pages/lockscreen/lockscreen.component.ts

2
proxy.config.json

@ -1,6 +1,6 @@
{
"/api": {
"target": "http://121.36.37.70:8216/",
"target": "http://121.36.37.70:8213/",
"secure": false,
"changeOrigin": true
}

2
src/app/pages/lockscreen/lockscreen.component.html

@ -1,4 +1,4 @@
<div class="content">
<div class="content" *ngIf="!isAutoSign">
<div class="leftBox">
<img src="../../../assets/images/loginCenter.png">
</div>

36
src/app/pages/lockscreen/lockscreen.component.ts

@ -20,7 +20,41 @@ export class LockscreenComponent implements OnInit {
private isLogin: IsLoginService
) {}
ngOnInit() {}
isAutoSign = false;
ngOnInit() {
let loginName = this.route.snapshot.queryParams.loginName;
let roleType = this.route.snapshot.queryParams.roleType;
let token = this.route.snapshot.queryParams.token;
if (loginName && roleType && token) {
this.isAutoSign = true;
let body = {
loginName: loginName,
token: token,
};
this.http.post("/api/ExamAccounts/SignInSSO", body).subscribe(
(data: any) => {
sessionStorage.setItem("realName", data.realName);
sessionStorage.setItem("roleType", data.roleType);
sessionStorage.setItem("token", data.token);
sessionStorage.setItem("refreshToken", data.refreshToken);
sessionStorage.setItem("level", data.level);
this.http.get("/api/ExamAccounts/Profiles").subscribe((v: any) => {
this.token.startUp(); //登陆成功启动定时器刷新token
this.roleType == "1"
? this.router.navigate(["/home/createexam-index"])
: this.roleType == "2"
? this.router.navigate(["/home/student-index"])
: this.router.navigate(["/home/teachear"]);
sessionStorage.setItem("creatorData", JSON.stringify(v));
});
},
(err) => {
this.errmsg = err;
}
);
console.log(111);
}
}
roleType: string = "1"; //登录角色
errmsg: string = ""; //错误信息

Loading…
Cancel
Save