瀏覽代碼

同济不使用登录加密

seimin 1 年之前
父節點
當前提交
2a3e643877
共有 3 個文件被更改,包括 27 次插入6 次删除
  1. 4 1
      src/app/app.component.ts
  2. 9 5
      src/app/services/main.service.ts
  3. 14 0
      src/app/services/marking.service.ts

+ 4 - 1
src/app/app.component.ts

@@ -1,17 +1,20 @@
1 1
 import { Component } from '@angular/core';
2 2
 import { Title } from '@angular/platform-browser';
3 3
 import { ToolService } from './services/tool.service';
4
+import { MarkingService } from './services/marking.service';
4 5
 @Component({
5 6
   selector: 'app-root',
6 7
   templateUrl: './app.component.html',
7 8
   styleUrls: ['./app.component.less']
8 9
 })
9 10
 export class AppComponent {
10
-  constructor(private titleService:Title, private tool:ToolService){
11
+  constructor(private titleService:Title, private tool:ToolService, private markingService: MarkingService){
11 12
     this.tool.getSysNameAndLogoAsync().subscribe(result => {
13
+      let marking = result.project || '';
12 14
       let logoTitle = result.sysName || '';
13 15
       let logoUrl = location.origin + '/file' + result.logo || '';
14 16
       let faviconUrl = location.origin + '/file' + result.favicon || '';
17
+      this.markingService.setMarking(marking);
15 18
       this.tool.setSysName(logoTitle);
16 19
       this.tool.setLogo(logoUrl);
17 20
       this.tool.setFavicon(faviconUrl);

+ 9 - 5
src/app/services/main.service.ts

@@ -4,12 +4,13 @@ import { HttpClient, HttpHeaders } from "@angular/common/http";
4 4
 import host from "../../assets/js/http";
5 5
 import { Observable } from "rxjs";
6 6
 import { AES, mode, pad, enc } from "crypto-js";
7
+import { MarkingService } from './marking.service';
7 8
 
8 9
 @Injectable({
9 10
   providedIn: "root",
10 11
 })
11 12
 export class MainService {
12
-  constructor(private http: HttpClient) {}
13
+  constructor(private http: HttpClient, private markingService: MarkingService) {}
13 14
 
14 15
   headers = new HttpHeaders({
15 16
     "Content-Type": "application/json",
@@ -34,14 +35,17 @@ export class MainService {
34 35
   }
35 36
   // 登录
36 37
   login(name: string, pwd: string): any {
37
-    let loginData = {
38
+    let data:any = {
38 39
       username: name,
39 40
       password: pwd,
40 41
       type: "PC",
41 42
     };
42
-    let data = {
43
-      k: this.encryptByEnAES(JSON.stringify(loginData))
44
-    };
43
+    // 同济登录不加密
44
+    if(this.markingService.marking !== 'tongji'){
45
+      data = {
46
+        k: this.encryptByEnAES(JSON.stringify(data))
47
+      };
48
+    }
45 49
     return this.http.post(host.host + "/auth/login", data, {
46 50
       headers: this.headers,
47 51
     });

+ 14 - 0
src/app/services/marking.service.ts

@@ -0,0 +1,14 @@
1
+import { Injectable } from '@angular/core';
2
+
3
+@Injectable({
4
+  providedIn: 'root'
5
+})
6
+export class MarkingService {
7
+  marking = '';
8
+  constructor() { }
9
+
10
+  // 设置项目标识
11
+  setMarking(marking){
12
+    this.marking = marking;
13
+  }
14
+}