Commit ed5e19a518ebe62aeb2db87c55a45854df2dcb37
1 parent
32ca0b8c
Exists in
master
and in
4 other branches
allow user to reset his private token
Showing
5 changed files
with
33 additions
and
1 deletions
Show diff stats
app/controllers/profile_controller.rb
@@ -25,4 +25,9 @@ class ProfileController < ApplicationController | @@ -25,4 +25,9 @@ class ProfileController < ApplicationController | ||
25 | render :action => "password" | 25 | render :action => "password" |
26 | end | 26 | end |
27 | end | 27 | end |
28 | + | ||
29 | + def reset_private_token | ||
30 | + current_user.reset_authentication_token! | ||
31 | + redirect_to profile_password_path | ||
32 | + end | ||
28 | end | 33 | end |
app/views/layouts/profile.html.haml
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | .fixed | 18 | .fixed |
19 | %aside | 19 | %aside |
20 | = link_to "Profile", profile_path, :class => current_page?(:controller => "profile", :action => :show) ? "current" : nil | 20 | = link_to "Profile", profile_path, :class => current_page?(:controller => "profile", :action => :show) ? "current" : nil |
21 | - = link_to "Password", profile_password_path, :class => current_page?(:controller => "profile", :action => :password) ? "current" : nil | 21 | + = link_to "Password & token", profile_password_path, :class => current_page?(:controller => "profile", :action => :password) ? "current" : nil |
22 | = link_to keys_path, :class => controller.controller_name == "keys" ? "current" : nil do | 22 | = link_to keys_path, :class => controller.controller_name == "keys" ? "current" : nil do |
23 | Keys | 23 | Keys |
24 | - unless current_user.keys.empty? | 24 | - unless current_user.keys.empty? |
app/views/profile/password.html.haml
@@ -18,3 +18,16 @@ | @@ -18,3 +18,16 @@ | ||
18 | .actions | 18 | .actions |
19 | = f.submit 'Save', :class => "lbutton vm" | 19 | = f.submit 'Save', :class => "lbutton vm" |
20 | 20 | ||
21 | +%br | ||
22 | +%br | ||
23 | +%br | ||
24 | + | ||
25 | += form_for @user, :url => profile_reset_private_token_path, :method => :put do |f| | ||
26 | + %p | ||
27 | + Current private token: | ||
28 | + %strong | ||
29 | + = current_user.private_token | ||
30 | + %em.cred | ||
31 | + keep it in secret! | ||
32 | + .actions | ||
33 | + = f.submit 'Reset', :confirm => "Are you sure?", :class => "lbutton vm" |
config/routes.rb
@@ -17,6 +17,7 @@ Gitlab::Application.routes.draw do | @@ -17,6 +17,7 @@ Gitlab::Application.routes.draw do | ||
17 | get "errors/gitosis" | 17 | get "errors/gitosis" |
18 | get "profile/password", :to => "profile#password" | 18 | get "profile/password", :to => "profile#password" |
19 | put "profile/password", :to => "profile#password_update" | 19 | put "profile/password", :to => "profile#password_update" |
20 | + put "profile/reset_private_token", :to => "profile#reset_private_token" | ||
20 | put "profile/edit", :to => "profile#social_update" | 21 | put "profile/edit", :to => "profile#social_update" |
21 | get "profile", :to => "profile#show" | 22 | get "profile", :to => "profile#show" |
22 | get "dashboard", :to => "dashboard#index" | 23 | get "dashboard", :to => "dashboard#index" |
spec/requests/profile_spec.rb
@@ -29,6 +29,19 @@ describe "Profile" do | @@ -29,6 +29,19 @@ describe "Profile" do | ||
29 | it { @user.twitter.should == 'testtwitter' } | 29 | it { @user.twitter.should == 'testtwitter' } |
30 | end | 30 | end |
31 | 31 | ||
32 | + describe "Reset private token" do | ||
33 | + before do | ||
34 | + visit profile_password_path | ||
35 | + end | ||
36 | + | ||
37 | + it "should reset private token" do | ||
38 | + user_first_token = @user.private_token | ||
39 | + click_button "Reset" | ||
40 | + @user.reload | ||
41 | + @user.private_token.should_not == user_first_token | ||
42 | + end | ||
43 | + end | ||
44 | + | ||
32 | describe "Password update" do | 45 | describe "Password update" do |
33 | before do | 46 | before do |
34 | visit profile_password_path | 47 | visit profile_password_path |