0
我是全新的rails(3.2),我正在尋找一種方法來允許用戶使用他們的數據庫ID和密碼登錄。閱讀文檔,Authlogic似乎允許使用登錄名或電子郵件進行登錄。是否有可能以某種方式擴展這種gem以允許用戶通過提供他們的數據庫ID和密碼進行身份驗證?Rails Authlogic:使用數據庫ID登錄
這裏是我當前的用戶模型
class User < ActiveRecord::Base
attr_accessible :password, :password_confirmation, :current_login_ip, :email, :failed_login_count, :first_name, :last_login_ip, :last_name, :last_request_at, :login_count, :password_salt,
:perishable_token, :persistence_token, :single_access_token
acts_as_authentic
end
而且我
class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Successfully logged in."
redirect_to root_url
else
render :action => 'new'
end
end
def destroy
if UserSession.find
UserSession.find.destroy
flash[:notice] = "Successfully logged out."
end
redirect_to root_url
end
end
我在安裝中使用的電子郵件地址驗證當前用戶會話模型。
在此先感謝!
在您發佈之前發現它!但是,這是解決方案,謝謝。 – Kieran 2012-08-12 21:28:31
如果你需要挖掘其他選項,效率會更高(所有選項都位於acts_as_authentic目錄中的模塊中)。 – Jef 2012-08-13 11:50:48