Class: Dailycred::UsersController

Inherits:
ApplicationController
  • Object
show all
Includes:
Helpers
Defined in:
app/controllers/dailycred/users_controller.rb

Instance Method Summary collapse

Methods included from Helpers

#authenticate, #connect_path, #connect_user, #dailycred, #login_path, #redirect_to_auth, #redirect_to_unauth, #set_state

Instance Method Details

#loginObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/dailycred/users_controller.rb', line 15

def 
  response = dailycred. params
  if response.success?
    @user = User.find_or_create_from_local_auth(response.user)
    session[:user_id] = @user.id
    flash[:notice] = "You have logged in successfully."
  else
    flash[:notice] = "There was a problem logging you in."
    flash[:login_error] = response.errors["message"]
    flash[:login_error_attribute] = response.errors["attribute"]
  end
  redirect_to_auth
end

#reset_passwordObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/dailycred/users_controller.rb', line 5

def reset_password
  if params[:user]
    dailycred.reset_password(params[:user])
    flash[:notice] = "Your password has been reset. See your email for further instructions."
  else
    flash[:notice] = "Please enter your email or password to continue."
  end
  redirect_to_auth
end

#signupObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/dailycred/users_controller.rb', line 29

def 
  response = dailycred. params
  if response.success?
    @user = User.find_or_create_from_local_auth(response.user)
    session[:user_id] = @user.id
    flash[:notice] = "You have signed up successfully."
  else
    flash[:notice] = "There was a problem logging you in."
    flash[:signup_error] = response.errors["message"]
    flash[:signup_error_attribute] = response.errors["attribute"]
  end
  redirect_to_auth
end