aboutsummaryrefslogtreecommitdiff
path: root/src/actions/sign_ins/create.cr
blob: af2258888e59f56d73cb237eec1adcd90dd39e46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class SignIns::Create < BrowserAction
  include Auth::RedirectSignedInUsers

  post "/sign_in" do
    SignInUser.run(params) do |operation, authenticated_user|
      if authenticated_user
        sign_in(authenticated_user)
        flash.success = "You're now signed in"
        Authentic.redirect_to_originally_requested_path(self, fallback: Home::Index)
      else
        flash.failure = "Sign in failed"
        html NewPage, operation: operation
      end
    end
  end
end