-
Notifications
You must be signed in to change notification settings - Fork 7
enhancement: added call to /sessioninfo
api from frontend in Non React framework
#124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
83753d0
a690dd3
31850f4
e42c3ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,36 +1,48 @@ | ||||||||||||||
import { AfterViewInit, Component } from "@angular/core"; | ||||||||||||||
import { afterviewinit, component } from "@angular/core"; | ||||||||||||||
import { httpclient } from "@angular/common/http"; | ||||||||||||||
|
||||||||||||||
import * as Session from "supertokens-web-js/recipe/session"; | ||||||||||||||
import Session from "supertokens-web-js/recipe/session"; | ||||||||||||||
|
||||||||||||||
@Component({ | ||||||||||||||
@component({ | ||||||||||||||
selector: "app-home", | ||||||||||||||
templateUrl: "./home.component.html", | ||||||||||||||
styleUrls: ["./home.component.css"], | ||||||||||||||
templateurl: "./home.component.html", | ||||||||||||||
styleurls: ["./home.component.css"], | ||||||||||||||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Angular decorator properties should maintain proper camelCase naming convention. Please update
Suggested change
Spotted by Diamond |
||||||||||||||
}) | ||||||||||||||
export class HomeComponent implements AfterViewInit { | ||||||||||||||
export class homecomponent implements afterviewinit { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class name and interface should maintain proper casing to match Angular conventions. Please update
Suggested change
Spotted by Diamond |
||||||||||||||
title = "angularapp"; | ||||||||||||||
|
||||||||||||||
public rootId = "rootId"; | ||||||||||||||
public userId = ""; | ||||||||||||||
public rootid = "rootid"; | ||||||||||||||
public userid = ""; | ||||||||||||||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The property names
Suggested change
Spotted by Diamond |
||||||||||||||
public session = false; | ||||||||||||||
|
||||||||||||||
ngAfterViewInit() { | ||||||||||||||
this.getUserInfo(); | ||||||||||||||
constructor(private http: httpclient) {} | ||||||||||||||
|
||||||||||||||
ngafterviewinit() { | ||||||||||||||
this.getuserinfo(); | ||||||||||||||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method names should follow Angular's naming conventions:
Suggested change
Spotted by Diamond |
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
async getUserInfo() { | ||||||||||||||
this.session = await Session.doesSessionExist(); | ||||||||||||||
async getuserinfo() { | ||||||||||||||
this.session = await session.doessessionexist(); | ||||||||||||||
if (this.session) { | ||||||||||||||
this.userId = await Session.getUserId(); | ||||||||||||||
this.userid = await session.getuserid(); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
async onLogout() { | ||||||||||||||
await Session.signOut(); | ||||||||||||||
async callapi() { | ||||||||||||||
this.http.get("http://localhost:3001/sessioninfo").subscribe( | ||||||||||||||
(data: any) => { | ||||||||||||||
alert(json.stringify(data, null, 2)); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The JavaScript global object name should be capitalized as
Suggested change
Spotted by Diamond |
||||||||||||||
}, | ||||||||||||||
(error: any) => { | ||||||||||||||
alert(`failed to fetch session info: ${error.message}`); | ||||||||||||||
} | ||||||||||||||
); | ||||||||||||||
} | ||||||||||||||
async onlogout() { | ||||||||||||||
await session.signout(); | ||||||||||||||
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a case mismatch in the method name and Session import usage. The method should be `onLogout()` (capital L) and use `Session.signOut()` to match both the template binding in the HTML (`(click)="onLogout()"`) and the import statement. Currently, Angular won't be able to find the method when the button is clicked.
Suggested change
Spotted by Diamond |
||||||||||||||
window.location.reload(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
redirectToLogin() { | ||||||||||||||
redirecttologin() { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method name
Suggested change
Spotted by Diamond |
||||||||||||||
window.location.href = "auth"; | ||||||||||||||
} | ||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { NgModule } from "@angular/core"; | ||
import { CommonModule } from "@angular/common"; | ||
import { HttpClientModule } from "@angular/common/http"; | ||
|
||
import { HomeRoutingModule } from "./home-routing.module"; | ||
import { HomeComponent } from "./home.component"; | ||
|
||
@NgModule({ | ||
declarations: [HomeComponent], | ||
imports: [CommonModule, HomeRoutingModule], | ||
imports: [CommonModule, HomeRoutingModule, HttpClientModule], | ||
}) | ||
export class HomeModule {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Angular imports need to be properly capitalized to match the actual class names in the framework. Please update:
to:
Angular's TypeScript imports are case-sensitive, and using incorrect casing will cause compilation errors.
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.