Sha256: 12bf3ef92ff2be338492d1f0432317dbcf55f29132ba205ed04ec1b1dd3cb4e2
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module NoPassword class SessionsController < ApplicationController include NoPassword::ControllerHelpers def new @return_to = params[:return_to].to_s @resource = Session.new end def create return_to = params[:return_to].to_s current_session = SessionManager.new.create(request.user_agent, params.dig(:session, :email), request.remote_ip, referrer_path(return_to)) if current_session.present? SessionsMailer.with(session: current_session).send_token.deliver_later after_session_request if respond_to?(:after_session_request) respond_to do |format| format.html { redirect_to no_password.edit_session_confirmations_path } format.turbo_stream end end end def destroy sign_out redirect_to main_app.root_path end private def referrer_path(return_to) referrer = CGI.unescape(return_to) return nil if referrer.blank? (referrer.include?(no_password.new_session_path) || referrer.include?(no_password.edit_session_confirmations_path)) ? nil : referrer end def sign_out(key = nil) session.delete(session_key) session.delete(session_key(key)) if key.present? @session = nil true end end end
Version data entries
4 entries across 4 versions & 1 rubygems