mailr/app/controllers/user_controller.rb

67 lines
1.2 KiB
Ruby
Raw Normal View History

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
2011-07-24 22:22:13 +02:00
user = User.find_by_email(params[:user][:email])
2011-07-23 21:55:26 +02:00
if user.nil?
2011-07-27 20:34:30 +02:00
redirect_to :action => 'unknown' ,:email=> params[:user][:email]
2011-07-23 21:55:26 +02:00
else
2011-07-29 20:05:47 +02:00
session[:user_id] = user.id
user.set_cached_password(session,params[:user][:password])
2011-07-24 22:22:13 +02:00
2011-07-29 20:05:47 +02:00
if session["return_to"]
redirect_to(session["return_to"])
session["return_to"] = nil
2011-07-23 21:55:26 +02:00
else
2011-07-29 20:05:47 +02:00
redirect_to :controller=> 'messages', :action=> 'refresh'
2011-07-23 21:55:26 +02:00
end
2011-07-29 20:05:47 +02:00
2011-07-23 21:55:26 +02:00
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
2011-07-27 20:34:30 +02:00
2011-07-23 21:55:26 +02:00
@user = User.new
@user.email = params["user_email"]
@user.first_name = params["user_first_name"]
@user.last_name = params["user_last_name"]
2011-07-27 20:34:30 +02:00
@server = Server.new
2011-07-23 21:55:26 +02:00
@server.name = params["server_name"]
2011-07-27 20:34:30 +02:00
2011-07-23 21:55:26 +02:00
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