Недопустимые параметры:: utf8,: authenticity_token,: auth_key,: пароль,: commit,: провайдер - PullRequest
0 голосов
/ 10 июня 2018

Я обновляю свое приложение до ruby ​​2.5.0 и Rails 5.1.4 (в Rails 5.2.0 те же ошибки)

Я использую omniauth_identity и omniauth_facebook.Здесь под ошибками:

Started POST "/auth/identity/callback" for 127.0.0.1 at 2018-06-09 15:43:37 -0500
I, [2018-06-09T15:43:37.167889 #95816]  INFO -- omniauth: (identity) Callback phase initiated.
MONGODB | localhost:27017 | fa250520_development.find | STARTED | {"find"=>"identities", "filter"=>{"code"=>"tester"}, "sort"=>{"_id"=>1}, "limit"=>1, "singleBatch"=>true, "lsid"=>{"id"=><BSON::Binary:0x70231503979480 type=uuid data=0xc8d708dc93a2465b...>}}
MONGODB | localhost:27017 | fa250520_development.find | SUCCEEDED | 0.002999s
Processing by SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"iPrBOcP/Anz86NofDpdOEMeDKJrpfMuJVCZVB7YR5aq5ZPvAojnqkdhfFNo3DZeeGbmhr4Z5NzobThWGlpK3fA==", "auth_key"=>"tester", "password"=>"[FILTERED]", "commit"=>"Sign In", "provider"=>"identity"}
MONGODB | localhost:27017 | fa250520_development.find | STARTED | {"find"=>"users", "filter"=>{"uid"=>"5b1b2b7e51d2f53acd37f601", "provider"=>"identity", "email"=>"tester@test.com"}, "sort"=>{"_id"=>1}, "limit"=>1, "singleBatch"=>true, "lsid"=>{"id"=><BSON::Binary:0x70231503979480 type=uuid data=0xc8d708dc93a2465b.....
MONGODB | localhost:27017 | fa250520_development.find | SUCCEEDED | 0.004510999999999999s
Unpermitted parameters: :utf8, :authenticity_token, :auth_key, :password, :commit, :provider
Redirected to http://localhost:3000/
Completed 302 Found in 9ms

Здесь сессия_контроллер:

encoding: utf-8
class SessionsController < ApplicationController
  def new
    @title= 'Sign In'
  end

  def create
    auth = request.env["omniauth.auth"]
    user = User.from_omniauth(auth)
    session[:user_id] = user.id
    if params.permit[:remember_me]
      cookies.permanent[:auth_token] = user.auth_token
    else
     cookies[:auth_token] = user.auth_token
    end
     refresh_to root_path, :ma_notice => "Logged in"
    rescue
     redirect_to root_path, :alert=> "Authentication failed, please try again."
  end

  def destroy
    cookies.delete(:auth_token)
    refresh_to root_path, :ma_notice => "Logged Out"
  end
end

Модель: user.rb

class User
  include Mongoid::Document
  before_create {generate_token(:auth_token)}
  field :provider, :type => String
  field :uid, :type => String
  field :code, :type => String
  field :email, :type => String
  field :role, :type => String
  field :user, :type => String
  field :auth_token, :type => String
  field :password_reset_token, :type => String
  field :password_reset_sent_at,:type => DateTime
  belongs_to :identity, :polymorphic => true, :optional => true

  def self.from_omniauth(auth)
    where(uid: auth.uid, provider: auth.provider, email: auth.info.email).first_or_create do |user|
    case auth.provider 
      when 'identity'
        identity = Identity.find auth.uid
        user.code = identity.code
        user.email = identity.email
      else
        user.email = auth.info.email
        user.uid = auth.uid
        user.provider = auth.provider
        user.code = auth.info.name
        user.role = "M"
      end
    end
  end

end

Здесь: views / session / new.html.erb

  <%= form_tag "/auth/identity/callback", {'data-ajax'=>'false'} do %>
  <div class="field" data-role="fieldcontain">
    <%= label_tag :auth_key, "User name" %>
    <%= text_field_tag :auth_key %>
  </div>
  <div class="field" data-role="fieldcontain">
    <%= label_tag :password, "Password" %>
    <%= password_field_tag :password %>
  </div>
      <div class="field" data-role="fieldcontain" data-icon="info">
      <%= label_tag :remember_me %>
      <%= check_box_tag :remember_me, 1, params.permit[:remember_me] %>
      </div>
  <div class="actions"><%= submit_tag "Sign In" %></div>
  <%= link_to 'Forgotten password?', new_password_reset_path, data: {icon: 'info', mini: 'true', role: 'button'} %>
<% end %>

Справка:

Как избавиться от неопубликованных параметров, нужно ли вставлять параметры в session_controller и как.Я не могу найти ни одного документа.

...