Sha256: de203f8864ec1ff1feef0110951e004e35c0d050d82b636a72bbbb30ce47e5c0

Contents?: true

Size: 718 Bytes

Versions: 6

Compression:

Stored size: 718 Bytes

Contents

class SessionsController < ApplicationController
	before_action :redirect_if_connected, except: :destroy

	def new
	end

	def create
		@user = User.where("lower(name) = ?", params[:session][:name].strip.downcase).first
		if @user && @user.authenticate(params[:session][:password])
			sign_in(@user, permanent: params[:session][:remember_me] == "1")
			redirect_back_or profile_path, success: t('snapuser.session.success')
		else
			flash.now[:error] = t('snapuser.session.error')
			render 'new'
		end
	end

	def destroy
		sign_out
		redirect_to root_path, success: t('snapuser.session.destroy.success')
	end

	private

	def redirect_if_connected
		redirect_to Snapuser.redirect_url unless current_user.nil?
	end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
snapuser-0.2.6 app/controllers/sessions_controller.rb
snapuser-0.2.5 app/controllers/sessions_controller.rb
snapuser-0.2.4 app/controllers/sessions_controller.rb
snapuser-0.2.3 app/controllers/sessions_controller.rb
snapuser-0.2.2 app/controllers/sessions_controller.rb
snapuser-0.2.1 app/controllers/sessions_controller.rb