akveo / akveo/nebular

The login almost occur error in production mode When config NbDummyAuthStrategy.

Open
#2,108 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.1k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

### Issue type

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

* [x] bug report
* [ ] feature request

### Issue description

**Current behavior:**
I config the NbDummyAuthStrategy for NbAuthModule.
deploy the app with command: `npm run build:prod`, when i login ,I get a error, it is a HttpErrorResponse, because there is a post request to the '/'. And the reponse is a html, and it is a valid json format.
but deploy the command: `npm run build`. It is ok.

**Expected behavior:**
The NbDummyAuthStrategy should can work in prod option. Because in demo mode, I want the login process is a complete whole although without the backend. The hope is that any account can work, and do not check whether it is valid or not, because that just show a demo.

**Steps to reproduce:**
1. config the NbDummyAuthStrategy for NbAuthModule
2. npm run build:prod
3. click the login submit
4. the NbAuthResult that is returned by authenticate almost error.

**Related code:**
the config code:
```
...NbAuthModule.forRoot({
strategies: [
NbPasswordAuthStrategy.setup({
name: 'email',
baseEndpoint: '',
login: {
endpoint: CommonEndpoint.login,
defaultMessages: ['登录成功。'],
requireValidToken: true,
},
logout: {
endpoint: CommonEndpoint.logout,
method: 'delete',
redirect: {
success: '/auth/login',
failure: '/auth/login',
},
},
token: {
class: NbAuthThinkOAuth2Token,
key: 'content',
},
}),
NbDummyAuthStrategy.setup({
token: {
class: NbAuthThinkSimpleToken,
},
name: 'dummy',
}),
],
forms: {
login: {
rememberMe: false,
strategy: Config.demoMode === true ? 'dummy' : 'email',
},
logout: {},
validation: {
password: {
required: true,
minLength: 6,
},
email: {
required: true,
},
},
},
}).providers
```
the console log:
```
errors: ["Login/Email combination is not correct, please try again."]
messages: [undefined]
redirect: null
response: x
error: {error: SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse () at XMLHtt…, text: "↵↵↵ ↵↵"}
headers: d {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
message: "Http failure during parsing for http://base.ngx-admin.localhost/"
name: "HttpErrorResponse"
ok: false
status: 200
statusText: "OK"
url: "http://base.ngx-admin.localhost/"
__proto__: _
success: false
token: null
```
### Other information:

**npm, node, OS, Browser**
```
node --version
# v10.16.0

npm --version
6.11.3

OS: Windows (10)
Browser: Chrome
```

**Angular, Nebular**

the `package.json` is ok.

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.