Class: Aadhar::PasswordsController
Instance Method Summary
collapse
#authenticate, #current_user
Instance Method Details
#reset ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/aadhar/passwords_controller.rb', line 26
def reset
@user = User.where(email: params[:email]).first
if @user.present?
@user.set_temporary_password
@user.change_password = true
@user.save
UserMailer.reset_email(@user, @user.temp_password).deliver_later
render :status => 200,
:json => { :success => true,
:info => "Check your email",
:data => { :user => {
id: @user.id,
email: @user.email,
name: @user.name
} }
}
else
render :status => 200,
:json => { :success => false,
:info => "No user exist with this email address" }
end
end
|
#update ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/aadhar/passwords_controller.rb', line 4
def update
current_user.password = params[:password]
current_user.password_confirmation = params[:password_confirmation]
current_user.change_password = false
if current_user.save
render :status => 200,
:json => { :success => true,
:info => "Password updated successfully",
:data => { :user =>
{
id: current_user.id,
email: current_user.email,
name: current_user.name
} }
}
else
render :status => 200,
:json => { :success => false,
:info => current_user.errors}
end
end
|