获取在创建用户个人资料期间创建的 JWT 令牌:Ember js

Get JWT Token Created During User profile creation : Ember js

我正在使用 ember-simple-auth 和 jwt 来验证用户配置文件,这是注册代码,注册后我不想打印创建的令牌值(在响应)在控制台

import Controller from '@ember/controller';

export default Controller.extend({
    actions: {
        signup: function(){
            var credentials = this.getProperties('name','identification','password');
            let list = this.store.createRecord('user', {
                name: credentials.name,
                email: credentials.identification,
                password: credentials.password
            });
            list.save();

        // I want to print the token value in console here

            this.setProperties({
                'name': '',
                'identification': '',
                'password': ''
            });


        }
    }
});

@Sreenath,既然你说 jwt 存储在服务中, 这就是你 console.log 的方式。


import Controller from '@ember/controller';
import { inject as service } from '@ember/service';

export default Controller.extend({
    nameOfService: service(),

    actions: {
        signup: function(){
            // ...

            // I want to print the token value in console here
            console.log(this.nameOfService.nameofPropertyThatJWTIsOn);

            // ...


        }
    }
});