Sha256: 10c6a43a6432b2c92152c63dd393d13c53349a189af89750f1fbae0706403639
Contents?: true
Size: 889 Bytes
Versions: 1
Compression:
Stored size: 889 Bytes
Contents
class SessionsController < ApplicationController # Login def new end def create username_or_email = "#{params[:email]}".downcase user = User.find_by_username_or_email(username_or_email) if username_or_email.present? if user && user.authenticate(params[:password]) login(user) respond_to do |format| format.json { head :no_content } format.html { redirect_back_or_default } end else respond_to do |format| format.json { render json: { errors: ["Invalid user name or password"], status: "error" }, status: 422 } format.html { flash.now[:error] = "Invalid user name or password" render :new } end end end # Logout def destroy logout respond_to do |format| format.json { head :no_content } format.html { redirect_to root_path } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authkit-0.0.1 | lib/generators/authkit/templates/app/controllers/sessions_controller.rb |