first release

This commit is contained in:
jomo
2013-05-31 22:26:22 +02:00
parent 149232ec0c
commit 8921d108e2
70 changed files with 1080 additions and 85 deletions

View File

@@ -0,0 +1,29 @@
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by_email(params[:email])
if user && user.authenticate(params[:password])
user.last_ip = request.remote_ip
user.save
if user.banned
flash[:alert] = "You are banned!"
redirect_to login_path
else
session[:user_id] = user.id
redirect_to root_path, :notice => "Logged in!"
end
else
flash[:alert] = "You're doing it wrong!"
redirect_to login_path
end
end
def destroy
session[:user_id] = nil
redirect_to root_path, :notice => "Logged out!"
end
end