akveo / akveo/ngx-admin

Problem with NbPasswordAuthStrategy on ngx-admin

Open
#5,549 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
25.7k
Forks
7.9k
PR merge metrics
No merged PRs in 30d

Description

### Issue type

**I'm submitting a ...** (check one with "x")

* [x] bug report
* [ ] feature request
* [ ] question about the decisions made in the repository

### Issue description
I have a problem using NbPasswordAuthStrategy implemented in the ngx-admin template because it doesn't show any errors but auth token is not saved.

**Current behavior:**
I implemented NbPasswordAuthStrategy with ngx-admin with my backend, the server is a nodejs using passport for security.
I am also using a custom Auth component for the login page just to be able to change some visuals.
The problem comes when I log in, the message of success appears but nothing happens. I also have configured the AuthGuard and when the AuthGuard calls isAuthenticated() function the result is false.

I don't know what's the problem, when I use my backend with postman security works just fine.

**Expected behavior:**
The expected behavior its saving the auth token so when calling isAuthenticated() functiion the result is true.

**Steps to reproduce:**
Implement custom auth login on the ngx-admin template using NbPasswordAuthStrategy.

My core.module.ts
```
strategies: [
NbPasswordAuthStrategy.setup({
name: 'email',
baseEndpoint: 'http://localhost:3700/api',
login: {
endpoint: '/auth/login',
method: 'post',
alwaysFail: false,
requireValidToken: false,
redirect: {
success: '/pages/inicio',
failure: null,
},
defaultErrors: ['Los datos no son correctos, por favor intente nuevamente.'],
defaultMessages: ['Sesión iniciada exitosamente.'],
},
register: {
endpoint: '/auth/register',
},
logout: {
alwaysFail: false,
endpoint: '/auth/logout',
method: 'get',
redirect: {
success: '/auth/login',
failure: null,
},
defaultErrors: ['Algo salio mal, intentalo nuevamente.'],
defaultMessages: ['Sesión cerrada exitosamente.'],
},
}),
],
}).providers,
```

### Other information:

**npm, node, OS, Browser**
node version: 10.16.3
npm version: 6.9.0
OS: Windows 10
Browser: Chrome/Edge/Vivaldi

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.