Gem 请教下怎么用 warden 做多个 sns 帐户关联

ghawkgu · 2013年06月29日 · 2842 次阅读

正在用 padrino,尝试利用 warden_omniauth 做用户认证和注册。 单个 sns 帐号认证没有问题,但是想在此基础上实现 devise 那样的多帐户关联。 但是发现 warden 的 session 只要有被认证的用户,就会跳过调用新的 stragegy 的过程。

看了 warden 的代码。lib/warden/proxy.rb 第 319 行,直接用 return 把后续的处理跳过了。

def _perform_authentication(*args)
    scope, opts = _retrieve_scope_and_opts(args)
    user = nil

    # Look for an existing user in the session for this scope.
    # If there was no user in the session. See if we can get one from the request.
    return user, opts if user = user(opts.merge(:scope => scope))
    _run_strategies_for(scope, args)

    if winning_strategy && winning_strategy.user
      opts[:store] = opts.fetch(:store, winning_strategy.store?)
      set_user(winning_strategy.user, opts.merge!(:event => :authentication))
    end

    [@users[scope], opts]
  end

想知道大家用 warden 的时候是怎么实现相关处理的。

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号