简体   繁体   English

用Rails进行简单身份验证设计用户名而不是电子邮件?

[英]ember simple auth with rails devise username instead of email?

I have a rails api that I am using devise for the login routine. 我有一个devis用于登录例程的rails api。 I hooked ember into that via ember simple auth. 我通过ember simple auth将ember插入其中。 Got it up and running using a typical devise email and password. 使用典型的设计电子邮件和密码启动并运行。 I typically configure devise though to use LDAP authentication which works great. 我通常将devise配置为使用LDAP身份验证,但效果很好。 The issue I am having is that I use a username for my LDAP login, not an email address. 我遇到的问题是我使用用户名进行LDAP登录,而不是电子邮件地址。 I usually change devise to look for a username and not an email address which I have done. 我通常会更改设计以查找用户名而不是我已经完成的电子邮件地址。

I am now getting a 401 unauthorized and looking at the params it looks like I am still sending an email across. 我现在收到未经授权的401,并查看参数,好像我仍在发送电子邮件。

Can you change ember simple auth to send a username and not email? 您可以更改ember简单身份验证以发送用户名而不发送电子邮件吗? If so how do you do that? 如果是这样,您该怎么做?

You have to extend the devise authorizer and set the identificationAttributeName to username 您必须扩展设计授权者,并将identificationAttributeName设置为username

// app/authorizers/devise.js
import DeviseAuthorizer from 'ember-simple-auth/authorizers/devise';

export default DeviseAuthorizer.extend({
  identificationAttributeName: 'username'
});

Source: ember-simple-auth 资料来源: ember-simple-auth

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM