2011-07-22 21:58:59 +02:00
|
|
|
class UserController < ApplicationController
|
2011-07-21 20:20:15 +02:00
|
|
|
|
2011-07-23 21:55:26 +02:00
|
|
|
theme :theme_resolver
|
|
|
|
layout "simple"
|
2011-07-21 20:20:15 +02:00
|
|
|
|
2011-07-23 21:55:26 +02:00
|
|
|
def login
|
|
|
|
end
|
2011-07-21 20:20:15 +02:00
|
|
|
|
2011-07-23 21:55:26 +02:00
|
|
|
def logout
|
|
|
|
reset_session
|
|
|
|
flash[:notice] = t(:user_logged_out)
|
|
|
|
redirect_to :action => "login"
|
|
|
|
end
|
2011-07-21 20:20:15 +02:00
|
|
|
|
2011-07-23 21:55:26 +02:00
|
|
|
def authenticate
|
|
|
|
user = User.find_by_email(params["user"]["email"])
|
|
|
|
if user.nil?
|
|
|
|
redirect_to :action => 'unknown'
|
|
|
|
else
|
2011-07-24 15:56:47 +02:00
|
|
|
auten = true
|
2011-07-23 21:55:26 +02:00
|
|
|
if auten == true
|
2011-07-24 15:56:47 +02:00
|
|
|
session[:user_id] = user.id
|
|
|
|
if session["return_to"]
|
|
|
|
redirect_to(session["return_to"])
|
|
|
|
session["return_to"] = nil
|
|
|
|
else
|
|
|
|
redirect_to :controller=> "messages",:action=>"index"
|
|
|
|
end
|
2011-07-23 21:55:26 +02:00
|
|
|
else
|
|
|
|
flash[:error] = t(:login_failure)
|
|
|
|
redirect_to :action => 'login'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-07-22 22:57:36 +02:00
|
|
|
|
2011-07-23 21:55:26 +02:00
|
|
|
def loginfailure
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@user = User.new
|
|
|
|
@server = Server.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def unknown
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@user = User.new
|
|
|
|
@server = Server.new
|
|
|
|
@user.email = params["user_email"]
|
|
|
|
@user.first_name = params["user_first_name"]
|
|
|
|
@user.last_name = params["user_last_name"]
|
|
|
|
@server.name = params["server_name"]
|
|
|
|
if @user.valid? and @server.valid?
|
|
|
|
@user.save
|
|
|
|
@server.user_id = @user.id
|
|
|
|
@server.save
|
2011-07-24 15:56:47 +02:00
|
|
|
Prefs.create_default(@user.id)
|
2011-07-23 21:55:26 +02:00
|
|
|
flash[:notice] = t(:setup_done)
|
|
|
|
redirect_to :action => 'login'
|
|
|
|
else
|
|
|
|
render "setup"
|
|
|
|
end
|
|
|
|
end
|
2011-07-21 20:20:15 +02:00
|
|
|
|
|
|
|
end
|