Skip to content

Commit 78c972e

Browse files
committed
Merge branch 'dev'
2 parents 881fdf6 + 2d74457 commit 78c972e

17 files changed

+264
-54
lines changed

package-lock.json

Lines changed: 111 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@angular/platform-browser-dynamic": "^9.0.4",
2525
"@angular/router": "^9.0.4",
2626
"@types/node": "^12.12.27",
27+
"angularx-qrcode": "^2.3.5",
2728
"bcryptjs": "^2.4.3",
2829
"chart.js": "^2.9.4",
2930
"classlist.js": "^1.1.20150312",

src/app/app-routing/app-routing.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { HealthCheckComponent } from '../health-check/health-check.component';
2323
import { VipAppsComponent } from '../vip-apps/vip-apps.component';
2424
import { VipAppComponent } from '../vip-app/vip-app.component';
2525
import { RefererComponent } from '../referer/referer.component';
26+
import { AuthcodeRegisterComponent } from '../authcode-register/authcode-register.component';
27+
2628

2729
const routes: Routes = [
2830
{ path: '', redirectTo: '/index.html', pathMatch: 'full' },
@@ -48,7 +50,8 @@ const routes: Routes = [
4850
{ path: 'login', component: LoginFormComponent},
4951
{ path: 'ssh', component: WebsshComponent },
5052
{ path: 'health', component: HealthCheckComponent },
51-
{ path: 'referring/:app_id/:host', component: RefererComponent }
53+
{ path: 'referring/:app_id/:host', component: RefererComponent },
54+
{ path: 'authcode-register', component: AuthcodeRegisterComponent}
5255
];
5356

5457
@NgModule({

src/app/app.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ import { HealthCheckComponent } from './health-check/health-check.component';
6767
import { VipAppsComponent } from './vip-apps/vip-apps.component';
6868
import { VipAppComponent } from './vip-app/vip-app.component';
6969
import { RefererComponent } from './referer/referer.component';
70+
import { QRCodeModule } from 'angularx-qrcode';
71+
import { AuthcodeRegisterComponent } from './authcode-register/authcode-register.component';
7072

7173
@NgModule({
7274
exports:[
@@ -136,7 +138,8 @@ export class MaterialModule{}
136138
HealthCheckComponent,
137139
VipAppsComponent,
138140
VipAppComponent,
139-
RefererComponent
141+
RefererComponent,
142+
AuthcodeRegisterComponent
140143
],
141144
imports: [
142145
MaterialModule,
@@ -145,7 +148,8 @@ export class MaterialModule{}
145148
FlexLayoutModule,
146149
FormsModule,
147150
HttpClientModule,
148-
AppRoutingModule
151+
AppRoutingModule,
152+
QRCodeModule
149153
],
150154
providers: [MessageService,
151155
ApplicationService,

src/app/application-detail/application-detail.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class ApplicationDetailComponent implements OnInit {
171171

172172
// get oauth config
173173
let self=this;
174-
this.applicationService.getResponseByURL('/janusec-admin/oauth/get',
174+
this.applicationService.getResponseByURL('/janusec-admin/oauth/info',
175175
function(obj: OAuthInfo){
176176
if(obj != null) self.oauth=obj;
177177
});

src/app/application.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export class ApplicationService {
2020
is_super_admin:false,
2121
is_cert_admin:false,
2222
is_app_admin:false,
23-
need_modify_pwd: false};
23+
need_modify_pwd: false,
24+
totp_key:"",
25+
totp_verified: false
26+
};
2427
certificates: Certificate[] = [];
2528
applications: Application[] = [];
2629
vip_apps: VipApp[] = [];

src/app/authcode-register/authcode-register.component.css

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="container">
2+
<h1 i18n="@@authenticator_register">Authenticator Registration</h1>
3+
<div i18n="@@authenticator_notice" class="notes">
4+
Please scan the following QRCode with Google Authenticator, or Microsoft Authenticator:
5+
</div>
6+
<qrcode [qrdata]="qrData" [width]="256" [errorCorrectionLevel]="'M'"></qrcode>
7+
<div>
8+
<span i18n="@@input_key_notice">
9+
Or input the Secret Key in your mobile app:
10+
</span>
11+
{{ applicationService.auth_user.totp_key }}
12+
</div>
13+
<br>
14+
<mat-form-field>
15+
<mat-label i18n="@@input_code_notice">Input 6-digit Code</mat-label>
16+
<input matInput [(ngModel)]="code" required>
17+
</mat-form-field>
18+
19+
<section>
20+
<button mat-button mat-stroked-button i18n="@@verify" (click)="verify()">Verify and Register</button>
21+
</section>
22+
23+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { AuthcodeRegisterComponent } from './authcode-register.component';
4+
5+
describe('AuthcodeRegisterComponent', () => {
6+
let component: AuthcodeRegisterComponent;
7+
let fixture: ComponentFixture<AuthcodeRegisterComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ AuthcodeRegisterComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(AuthcodeRegisterComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { MessageService } from '../message.service';
3+
import { ApplicationService } from '../application.service';
4+
import { Router } from '@angular/router';
5+
6+
@Component({
7+
selector: 'app-authcode-register',
8+
templateUrl: './authcode-register.component.html',
9+
styleUrls: ['./authcode-register.component.css']
10+
})
11+
export class AuthcodeRegisterComponent implements OnInit {
12+
qrData: string;
13+
code: string;
14+
15+
constructor(
16+
public applicationService: ApplicationService,
17+
private messageService: MessageService,
18+
private router: Router) { }
19+
20+
ngOnInit(): void {
21+
this.qrData = "otpauth://totp/" + this.applicationService.auth_user.username + "?secret=" + this.applicationService.auth_user.totp_key + "&issuer=JANUSEC";
22+
}
23+
24+
verify() {
25+
let body={action:"verify_totp", uid: this.applicationService.auth_user.username, code: this.code}
26+
var self = this;
27+
this.applicationService.getResponseByCustomBody(body, function() {
28+
self.messageService.add('verify ok, please login');
29+
self.router.navigate(['/login']);
30+
})
31+
}
32+
33+
}

0 commit comments

Comments
 (0)