Tag: 登录设备

用户登录失败后设计重定向

我知道有一个关于它的维基页面 ,但由于我对Rails很新,我在理解该页面时遇到了很多困难。 我不得不为我的用户覆盖注册控制器。 当用户无法登录时,我希望将他重定向到我的自定义登录页面。 但应用程序将他发送到gem内的登录页面。 我怎么能做到这一点? 我应该把这个课程放在哪里,如何更改? 我有多个模型,每个模型都有不同的登录页面。 如何设置每个型号的范围? class CustomFailure ‘secure’) end # You need to override respond to eliminate recall def respond if http_auth? http_auth else redirect end end 结束 Devise是一个强大的gem,但是一些wiki页面并不认为可以有很多新的程序员

重定向适用于登录但不适用于注销

说明 我正在使用带有Ruby on Rails webapp的devise gem,并按照本教程介绍如何在用户登录和注销后将用户重定向回上一页。 问题是,代码似乎适用于登录部分,但注销总是将用户重定向到root_path。 题 当我完全按照教程,并且重定向适用于一个,我是否错过了一个错字或者其他地方的代码是否覆盖了这段代码? 使用的版本 Ruby:ruby 2.2.1p85(2015-02-26修订版49769)[x86_64-darwin14] Rails:Rails 4.2.0 设计:3.4.1 码 应用控制器: ## app/controllers/application_controller.rb class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception after_filter :store_location before_action :configure_permitted_parameters, if: :devise_controller? def store_location # store last […]

设计 – 从两个模型登录

我有两个用户模型,第一个来自远程数据库作为遗留和内部公司目的。 (员工登录)。 其次是我们的公共注册项目并登录,但我想要一个登录表单。 我已经搜索了很长时间,但有些解决方案对我来说很困惑。 第一个遗产看起来像(仅用于阅读和身份validation): class CrmUser [:login] alias_attribute :encrypted_password, :crypted_password alias_attribute :password_salt, :salt # Setup accessible (or protected) attributes for your model attr_accessible :login, :password, :password_confirmation, :remember_me, :role_id, :first_name, :last_name 第二,对于公众和注册: class User [:login] alias_attribute :login, :email # Setup accessible (or protected) attributes for your model attr_accessible :login, :password, :password_confirmation, :remember_me, :role_id, :first_name, :last_name […]