Skip to content

Conversation

gitcommitshow
Copy link

Summary of change

Passwordless implementation in angular using supertokens-web-js

@rishabhpoddar rishabhpoddar changed the base branch from master to 0.1 August 9, 2022 13:19
Object.assign(this.user, userAndPayloadInfo);
}).catch((err) => {
console.log(err);
this.router.navigate["/login"];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a syntax error in the navigation method call. The correct syntax is this.router.navigate(['/login']) with parentheses for the method call rather than square brackets. The current code this.router.navigate["/login"] is attempting to access a property of the navigate object rather than calling the navigate method.

Suggested change
this.router.navigate["/login"];
this.router.navigate(["/login"]);

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +49 to +53
app.use(function(req, res, next){
console.log(req.url);
console.log(req.headers);
console.log(req.body || (req.method + " method"));
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The middleware function is missing a call to next(), which will cause all requests to hang indefinitely. To fix this issue, add next() at the end of the function:

app.use(function(req, res, next){
  console.log(req.url);
  console.log(req.headers);
  console.log(req.body || (req.method + " method"));
  next(); // Add this line to continue the request processing
});

Without this call, Express won't proceed to subsequent middleware or route handlers.

Suggested change
app.use(function(req, res, next){
console.log(req.url);
console.log(req.headers);
console.log(req.body || (req.method + " method"));
})
app.use(function(req, res, next){
console.log(req.url);
console.log(req.headers);
console.log(req.body || (req.method + " method"));
next();
});

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +18 to +20
if(this.router.getCurrentNavigation().extras.state && this.router.getCurrentNavigation().extras.state.errorText){
this.errorText = this.router.getCurrentNavigation().extras.state.errorText;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code as written may cause a null reference error if getCurrentNavigation() returns null, which can happen when the component is not initialized during a navigation event. To prevent this, consider using optional chaining:

const navigation = this.router.getCurrentNavigation();
if (navigation?.extras?.state?.errorText) {
  this.errorText = navigation.extras.state.errorText;
}

This approach safely handles cases where any part of the navigation chain is undefined or null.

Suggested change
if(this.router.getCurrentNavigation().extras.state && this.router.getCurrentNavigation().extras.state.errorText){
this.errorText = this.router.getCurrentNavigation().extras.state.errorText;
}
const navigation = this.router.getCurrentNavigation();
if(navigation?.extras?.state?.errorText){
this.errorText = navigation.extras.state.errorText;
}

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +1 to +3
export const environment = {
production: true
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The production environment configuration is missing the same properties that are defined in the development environment: apiDomain, apiBasePath, and appName. These properties are required by the AuthService for proper initialization. Consider adding these with appropriate production values:

export const environment = {
  production: true,
  apiDomain: "https://your-production-api-domain.com",
  apiBasePath: "/api",
  appName: "SuperTokens Passwordless Demo - Angular"
};
Suggested change
export const environment = {
production: true
};
export const environment = {
production: true,
apiDomain: "https://your-production-api-domain.com",
apiBasePath: "/api",
appName: "SuperTokens Passwordless Demo - Angular"
};

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant