class Api::V1::SessionsController < Devise::SessionsController
def create
if User.find_by(member_id: params[:user][:member_id])
self.resource = warden.authenticate!(auth_options)
sign_in(resource_name, resource)
resource.reset_authentication_token!
resource.save!
else
error :not_found
end
end
end
如何更改创建操作以确保只有具有角色的用户member
才能登录:“”。例如管理员(user.role => :admin
)得到error => :unauthorized