britton-jb / sentinel

DEPRECATED - Phoenix Authentication library that wraps Guardian for extra functionality
MIT License
106 stars 19 forks source link

Custom redirect paths #42

Open trestrantham opened 7 years ago

trestrantham commented 7 years ago

Has there been any thought on accommodating custom redirect paths? I really like how coherence handles these (https://github.com/smpallen99/coherence#customizing-redirections) but they could just as easily be added as a configuration with something like this, too:

config :sentinel,
  redirects: %{
    auth_callback: {:controller, :action},
    password_create: {:controller, :action}
  }
britton-jb commented 7 years ago

I hadn't thought about customizing redirects at this point, but would be open to it. Just not a use case I've personally had yet.

trestrantham commented 7 years ago

Ok cool. 😎 I can whip up another PR tonight to abstract redirection logic into a RedirectHelper. Any preference on exposing this to the user/dev as a module or configuration option?

sgeos commented 7 years ago

I am also interested in seeing custom redirects.

sgeos commented 7 years ago

So far as I can tell, custom redirect configuration is actually in the latest GitHub code. This functionality does not appear to be documented, nor does it appear to be in the standard (non-GitHub) version 2.0.1.

The following snippets can be used to change the post login redirect. The list of redirect keys can be found by calling Sentinel.Config.redirects() from iex -S mix.

mix.exs

  defp deps do
    [
      {:sentinel, git: "https://github.com/britton-jb/sentinel.git"}
    ]
  end

config/config.exs

config :sentinel,
  redirects: %{
    session_create: "/some/other/page"
  }
britton-jb commented 7 years ago

Currently master and the latest hex release have diverged, I'm working on a few more changes before the next release because the next hex release will contain breaking changes, and I want to get all of the breaking changes that are on the immediate horizon out of the way. Sorry about the confusion. I'll make sure to be more clear about that in the future, and update the README to reflect that.

britton-jb commented 7 years ago

A PR with this code has been merged, I'm just working on wrapping up the lockable code for v3 before we increment the hex version, because it will include other small breaking API changes.

britton-jb commented 6 years ago

This is currently available for careful testing in the features/lockable_and_plug branch.