ruby-on-rails – 覆盖omniauth身份的“/ auth / identity”页面
发布时间:2020-12-16 23:16:15 所属栏目:百科 来源:网络整理
导读:我正在使用没有设计的omniauth进行身份验证,因为我喜欢它的简单性.除了omniauth-facebook,我使用omniauth-identity来提供email / pw-authentication. railscast on omniauth-identity描述了如何设置自定义注册和登录页面.但仍可访问identity(/ auth / identi
我正在使用没有设计的omniauth进行身份验证,因为我喜欢它的简单性.除了omniauth-facebook,我使用omniauth-identity来提供email / pw-authentication.
railscast on omniauth-identity描述了如何设置自定义注册和登录页面.但仍可访问identity(/ auth / identity和/ auth / identity / register)提供的默认路由. 我想让这些在我的控制之下,因为我只想让受邀用户注册.有没有办法覆盖机架中间件提供的那些路由? match "/auth/identity",to: "somewhere#else" 不做的伎俩! 是否可能有配置来关闭这些默认路由?文档没有提供任何有关此…的详细信息 不幸的是我对Rack很新,??所以我还没有足够的洞察力来解决这个问题! 解决方法
OmniAuth策略对象有一个方法request_phase,它生成一个html表单并将其显示给用户.对于“omniauth-identity”策略,这将是您在/ auth / identity url中看到的表单.
您可以覆盖request_phase方法并将表单生成器替换为例如重定向到自定义登录页面(假设您在/ login url中可用).将以下内容与omniauth初始化代码一起放置: module OmniAuth module Strategies class Identity def request_phase redirect '/login' end end end end # Your OmniAuth::Builder configuration goes here... (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |