Skip to content

Commit b38a90b

Browse files
committed
fix: backend integration bugs and status messages
1 parent f87b04f commit b38a90b

19 files changed

+226
-63
lines changed

app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ app.use(function(req, res, next){
4242
} else {
4343
req.wantsJson = true;
4444
}
45+
console.debug(new Date().toString() + "Requested :: ", req.method, req.url);
46+
console.debug(req.headers)
4547
next();
4648
})
4749

frontend/src/app/generate-token/generate-token.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ <h1 class="mb-5 heading">{{ "generate-token.create" | transloco }}</h1>
22

33
<hr>
44

5-
<p class="justify-content-sm-between d-flex algo">
5+
<div class="justify-content-sm-between d-flex algo">
66
<span>{{ "generate-token.algorithm" | transloco }}</span>
77
<a target="_blank" href="https://tools.ietf.org/html/rfc7518#section-3">Recommend algorithms</a>
8-
</p>
8+
</div>
99

1010
<form #postForm="ngForm" (ngSubmit)="onCreateToken(postForm.value)">
1111
<select [(ngModel)]="algo" name="algo" class="rectangle">
1212
<option>HS256</option>
1313
<option [selected]="true">RS256</option>
1414
<option>ES256</option>
1515
</select>
16-
17-
<p class="font-grey algo">{{"generate-token.data" | transloco}}</p>
16+
<br/>
17+
<div class="font-grey algo">{{"generate-token.data" | transloco}}</div>
1818

1919
<textarea [(ngModel)]="payloadValue" name="payload" class="rectangle-1 data1"></textarea>
2020

frontend/src/app/generate-token/generate-token.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { StepService } from '../shared/services/step.service';
1111
export class GenerateTokenComponent implements OnInit {
1212

1313
payloadValue = '{ "data" : "We raised series A" }'
14-
algo ="RS256"
14+
//TODO Update payload to {"data":"This is Pradeep with id xyz and he can access files owned by xyz","iat":1646252217,"exp":1646338617,"aud":"supertokens.com","iss":"Supertokens Inc","sub":"auth@supertokens.com"}
15+
16+
algo ="HS256"
1517

1618
@Input() token = ""
1719

frontend/src/app/send-jwt1/send-jwt1.component.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ <h1 class="mb-3 heading">{{ "send-jwt1.introduction" | transloco }}</h1>
44

55
<hr>
66

7-
<div *ngIf="successToken" class="rectangle">
7+
<div *ngIf="successText" class="rectangle">
88
<img src="assets/images/icon-check-square.png"/>
9-
<span>{{ "send-jwt1.authenticated" | transloco | uppercase }}</span>
9+
<span>{{ successText | transloco | uppercase }}</span>
10+
</div>
11+
12+
<div *ngIf="errorText" class="rectangle error">
13+
<img src="assets/images/icon-error.svg"/>
14+
<span>{{ errorText | transloco | uppercase }}</span>
1015
</div>
1116

1217
<div class="rectangle1">

frontend/src/app/send-jwt1/send-jwt1.component.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
}
2121
}
2222

23+
.rectangle.error {
24+
border: solid 1px rgba(255, 5, 5, 0.75);
25+
background-color: rgba(209, 66, 31, 0.15);
26+
}
27+
2328
.rectangle1 {
2429
width: 668px;
2530
height: 405px;
@@ -29,7 +34,7 @@
2934
border: dashed 1px #505255;
3035

3136
.box {
32-
width: 331.1px;
37+
width: fit-content;
3338
height: 30.5px;
3439
padding: 6px 12.2px 8.5px 12.3px;
3540
border-radius: 6px;

frontend/src/app/send-jwt1/send-jwt1.component.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { HttpErrorResponse } from '@angular/common/http';
12
import { Component, OnInit } from '@angular/core';
23
import { Router } from '@angular/router';
34
import { DemoService } from '../shared/services/demo.service';
@@ -17,16 +18,26 @@ export class SendJwt1Component implements OnInit {
1718
) {
1819
this.stepService.setStep(7)
1920
}
21+
2022
ngOnInit(): void {
2123
}
22-
successToken = false
24+
25+
successText = "";
26+
errorText = "";
27+
2328
sendJwtThroughRequestParameter(){
2429
var myToken = localStorage.getItem('token')
25-
this.demoService.remote().getFromRequestParameter(myToken).subscribe({
30+
this.demoService.remote().sendTokenViaRequestParam(myToken).subscribe({
2631
next: (success: any)=>{
27-
this.successToken = true
28-
}, error: (error: any) => {
29-
console.error('error:', error);
32+
console.log("success")
33+
this.errorText = ""
34+
this.successText = success && success.statusText ? success.statusText : "Authenticated"
35+
},
36+
complete: () => console.log("Sent token in request parameter"),
37+
error: (error: HttpErrorResponse) => {
38+
this.successText = "";
39+
this.errorText = error.statusText || "Unsuccessful"
40+
console.error('error:', error)
3041
},
3142
})
3243
}

frontend/src/app/send-jwt2/send-jwt2.component.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ <h1 class="mb-3 heading">{{ "send-jwt2.introduction" | transloco }}</h1>
44

55
<hr>
66

7-
<div class="rectangle">
8-
<img src="assets/images/icon-check-square.png"/>
9-
<span>{{ "send-jwt2.authenticated" | transloco | uppercase }}</span>
7+
<div *ngIf="successText" class="rectangle">
8+
<img src="assets/images/icon-check-square.png"/>
9+
<span>{{ successText | transloco | uppercase }}</span>
10+
</div>
11+
12+
<div *ngIf="errorText" class="rectangle error">
13+
<img src="assets/images/icon-error.svg"/>
14+
<span>{{ errorText | transloco | uppercase }}</span>
1015
</div>
1116

1217
<div class="rectangle1">

frontend/src/app/send-jwt2/send-jwt2.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
}
2121
}
2222

23+
.rectangle.error {
24+
border: solid 1px rgba(255, 5, 5, 0.75);
25+
background-color: rgba(209, 66, 31, 0.15);
26+
}
27+
2328
.rectangle1 {
2429
width: 668px;
2530
height: 419px;

frontend/src/app/send-jwt2/send-jwt2.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export class SendJwt2Component implements OnInit {
1212

1313
token: any | null
1414

15+
successText = "";
16+
errorText = "";
17+
1518
constructor(
1619
private router : Router,
1720
private demoService : DemoService,
@@ -26,12 +29,15 @@ export class SendJwt2Component implements OnInit {
2629
}
2730

2831
sendJwtThroughBody(value: string){
29-
this.token = value
30-
this.demoService.remote().postFromBody(value).subscribe({
32+
this.demoService.remote().sendTokenViaWebFormBody(value).subscribe({
3133
next: (success: any)=>{
32-
console.log('yes')
34+
console.log('Authenticated')
35+
this.errorText = "";
36+
this.successText = success && success.statusText ? success.statusText : "You have been successfully authenticated"
3337
}, error: (error: any) => {
3438
console.error('error:', error);
39+
this.successText = "";
40+
this.errorText = error && error.statusText ? error.statusText : "Authentication failed"
3541
},
3642
})
3743
}

frontend/src/app/send-jwt3/send-jwt3.component.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ <h1 class="mb-3">{{ "send-jwt3.introduction" | transloco }}</h1>
44

55
<hr>
66

7-
<div class="rectangle">
7+
<div *ngIf="successText" class="rectangle">
88
<img src="assets/images/icon-check-square.png"/>
9-
<span>{{ "send-jwt3.authenticated" | transloco | uppercase }}</span>
9+
<span>{{ successText }}</span>
10+
</div>
11+
12+
<div *ngIf="errorText" class="rectangle error">
13+
<img src="assets/images/icon-error.svg"/>
14+
<span>{{ errorText | transloco | uppercase }}</span>
1015
</div>
1116

1217
<div class="rectangle1">
@@ -17,18 +22,13 @@ <h1>{{ "send-jwt3.request" | transloco }}</h1>
1722
<div class="innerRectangle">
1823
<div class="sampleContent">
1924
<pre id="responseText">
20-
<b>Sample Response</b>
21-
HTTP/1.1 200 OK
22-
Content-Type: application/json;charset=UTF-8
23-
Cache-Control: no-store
24-
Pragma: no-cache
25-
26-
{{'send-jwt3.openBracket' | transloco}}
27-
"access_token":"mF_9.B5f-4.1JqM",
28-
"token_type":"Bearer",
29-
"expires_in":3600,
30-
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA"
31-
{{ 'send-jwt3.closeBracket' | transloco}}
25+
<b>Sample Request</b>
26+
Request URL: /demo/protected/api/bearer
27+
Request Method: GET
28+
29+
--Headers--
30+
Content-Type: application/json
31+
Authorization: "Bearer thetoken"
3232
</pre>
3333
</div>
3434
<a href="#" class="edit">

0 commit comments

Comments
 (0)