Sha256: e433bc378ef31c0d6890a40827978c71b415aaf8226eb3123f6b6b118e51207f
Contents?: true
Size: 1.15 KB
Versions: 11
Compression:
Stored size: 1.15 KB
Contents
class Sessions::PasswordlessesController < ApplicationController skip_before_action :authenticate <%- if options.lockable? -%> before_action :require_lock, only: :create <%- end -%> before_action :set_user, only: :edit def new end def edit @session = @user.sessions.create! cookies.signed.permanent[:session_token] = { value: @session.id, httponly: true } revoke_tokens; redirect_to(root_path, notice: "Signed in successfully") end def create if @user = User.find_by(email: params[:email], verified: true) send_passwordless_email redirect_to sign_in_path, notice: "Check your email for sign in instructions" else redirect_to new_sessions_passwordless_path, alert: "You can't sign in until you verify your email" end end private def set_user @token = SignInToken.find_signed!(params[:sid]); @user = @token.user rescue redirect_to new_sessions_passwordless_path, alert: "That sign in link is invalid" end def send_passwordless_email UserMailer.with(user: @user).passwordless.deliver_later end def revoke_tokens @user.sign_in_tokens.delete_all end end
Version data entries
11 entries across 11 versions & 1 rubygems