net :: smtpauthenticationerror in Devise :: passwordscontrol



,因为我升级到rails 5,密码重置电子邮件不再可行。正如对所有相关问题的回答所暗示的那样,我的Gmail设置为接受较不安全的应用程序登录,验证码已关闭

当我单击"发送给我的Localhost上的重置密码指令"(也不在生产中起作用,但我首先要调试(,错误消息是

Net::SMTPAuthenticationError in Users::PasswordsController#create 535-5.7.8 Username and Password not accepted.
    Extracted source (around line #19):
17 puts resource_class
18 puts resource_params
19 self.resource = resource_class.send_reset_password_instructions(resource_params)

路由:

  devise_for :users, :skip => [:sessions, :passwords], controllers: {registrations: "users/registrations", passwords: "users/passwords"}      as :user do
    get 'login' => 'devise/sessions#new', :as => :new_user_session
    post 'login' => 'devise/sessions#create', :as => :user_session
    delete 'signout' => 'devise/sessions#destroy', :as => :destroy_user_session
    get "signup", :to => 'devise/registrations#new', :as => :new_user_signup
    post "signup", :to => 'devise/registrations#create', :as => :user_signup
    get "password", :to => 'devise/passwords#new', :as => :reset_password
    get "password", :to => 'devise/passwords#edit', :as => :edit_user_password
    match '/password' => 'users/passwords#create', as: :user_password, via: [:post]
    match '/password' => 'devise/passwords#update', via: [:put, :patch]
  end

设计/密码/新:

<%= form_for(resource, :as => resource_name, :url => user_password_path, :html => { :method => :post }) do |f| %>
  <%= devise_error_messages! %>
  <div><%= f.label :email %><br />
  <%= f.email_field :email, :autofocus => true, :size => 40 %></div>
  <div><%= f.submit "Send me reset password instructions" %></div>
<% end %>
<%= render "devise/shared/links" %>

development.rb:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => 587,
  :domain => "mail.google.com",
  :user_name => "me@gmail.com",
  :password => "GMAIL_PWD",
  :authentication => :plain,
  :enable_starttls_auto => true,
  :openssl_verify_mode => 'none'
}
config.action_mailer.default_url_options = {
  :host => 'localhost:3000', :protocol => 'http' 
}

user.rb:

  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable

控制器/用户/passwords_controller.rb:

class Users::PasswordsController < Devise::PasswordsController
  include ApplicationHelper
  prepend_before_action :require_no_authentication
  def create
    puts resource_class
    puts resource_params
    self.resource = resource_class.send_reset_password_instructions(resource_params)
    yield resource if block_given?
    if successfully_sent?(resource)
      respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
    else
      respond_with(resource)
    end
  end
end

application_helper.rb:

module ApplicationHelper
  def resource_name
    :user
  end
  def devise_mapping
    @devise_mapping ||= Devise.mappings[:user]
  end
end

这不是Gmail不允许从应用程序签名的其他100个问题的重复。我曾经有这个问题,但总是会从Gmail通知外,称外国应用程序正在访问Gmail帐户。在这种情况下,我的应用似乎还不够远,无法从Gmail访问。

我已经清除了验证码,已启用了pop/imap,在gmail中打开了较低的安全应用程序。它没有开发或生产。正如我提到的,我认为它甚至无法访问Gmail。我认为这与Rails 5&amp之间的兼容性问题;设计4.当我升级时,注册&amp;密码停止工作。我能够找到有效的示例registrations_controller,但尚未找到有关如何处理passwords_controller的任何文档。

这里发生了很多事情,我弄乱了很多,终于使这项工作在生产中&amp;发展。

'gmail_pwd'in Development.rb中的引号。gmail_pwd在config/initializers/keys.rb中定义。当我使用实际密码而不是变量时,它起作用。因此,我将开发.rb放入.gitignore。

现在它也可以在生产中起作用,尽管我不知道哪些解决方案有所帮助。

相关内容

  • 没有找到相关文章

最新更新