2

我对 aurelia-auth 有以下问题,这是我使用的常见登录片段:

login() {
    return this.authService.login(this.email, this.password)
    .then(response => {
        console.log("Login response" + JSON.stringify(response));
    })
    .catch(err => {
        this.loginError = err.response;
    });
};

当我尝试登录时,我看到了所需的控制台输出,但还有一条来自 authorizeStep.js:38 的消息“登录路由:/登录” ,表明我实际上没有经过身份验证

我的身份验证配置:

var config = {
  baseUrl: '',
  loginUrl:'http://localhost:8888/rest-auth/login/',
  signupUrl: 'http://localhost:8888/rest-auth/registration/',
  loginRedirect: '#/contests',
  logoutRedirect: '/',
  tokenName: 'key',
  authHeader: 'Authorization',
  authToken: 'Token',
  storage: 'sessionstorage'
}
export default config;

应用程序.js:

import {inject} from 'aurelia-framework';
import {Router} from 'aurelia-router';
import AppRouterConfig from 'router-config';
import HttpClientConfig from 'aurelia-auth/app.httpClient.config';
import {FetchConfig} from 'aurelia-auth';

@inject(Router, HttpClientConfig, FetchConfig, AppRouterConfig)
export class App {

  constructor(router, httpClientConfig, fetchConfig, appRouterConfig {
    this.router = router;
    this.httpClientConfig = httpClientConfig;
    this.appRouterConfig = appRouterConfig;
    this.fetchConfig = fetchConfig;
  }

  activate() {
    this.httpClientConfig.configure();
    this.appRouterConfig.configure();
    this.fetchConfig.configure();
  }
}

任何帮助,将不胜感激。

4

0 回答 0