moved auth token to admins page, and added a link in the dropdown
This commit is contained in:
parent
925292a7b2
commit
3c4c62abd5
8 changed files with 23 additions and 14 deletions
|
|
@ -28,6 +28,13 @@ class AdminsController < ApplicationController
|
|||
|
||||
redirect_to :back, :notice => notice, :user => {:id => u.id}
|
||||
end
|
||||
|
||||
def generate_new_token
|
||||
current_user.reset_authentication_token!
|
||||
current_user.authentication_token
|
||||
redirect_to user_search_path, :notice => "auth token reset"
|
||||
end
|
||||
|
||||
def admin_inviter
|
||||
opts = {:service => 'email', :identifier => params[:identifier]}
|
||||
existing_user = Invitation.find_existing_user('email', params[:identifier])
|
||||
|
|
|
|||
|
|
@ -76,9 +76,9 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def redirect_unless_admin
|
||||
admins = AppConfig[:admins]
|
||||
unless admins.present? && admins.include?(current_user.username)
|
||||
redirect_to root_url
|
||||
unless current_user.admin?
|
||||
redirect_to root_url, :notice => 'you need to be an admin to do that'
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -141,14 +141,4 @@ class UsersController < ApplicationController
|
|||
tar_path = PhotoMover::move_photos(current_user)
|
||||
send_data( File.open(tar_path).read, :filename => "#{current_user.id}.tar" )
|
||||
end
|
||||
|
||||
before_filter :redirect_unless_admin, :only => :generate_new_token
|
||||
def generate_new_token
|
||||
if current_user.reset_authentication_token!
|
||||
@token = current_user.authentication_token
|
||||
else
|
||||
@token = "No token created"
|
||||
end
|
||||
render :text => @token
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -322,6 +322,10 @@ class User < ActiveRecord::Base
|
|||
OpenSSL::PKey::RSA.new(serialized_private_key)
|
||||
end
|
||||
|
||||
def admin?
|
||||
AppConfig[:admins].present? && AppConfig[:admins].include?(self.username)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def remove_person
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@
|
|||
= link_to "add 10 invites for this user", add_invites_path(:user_id => user.id)
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%h3 your auth token
|
||||
%h2= current_user.authentication_token
|
||||
= link_to "reset auth token", new_auth_token_path
|
||||
%br
|
||||
= javascript_include_tag 'apiconsole'
|
||||
#query
|
||||
%h3 api console
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@
|
|||
= link_to current_user.name, '#'
|
||||
%li= link_to t('.profile'), current_user.person
|
||||
%li= link_to t('.settings'), edit_user_path
|
||||
-if current_user.admin?
|
||||
%li= link_to t('.admin'), user_search_path
|
||||
%li= link_to t('.logout'), destroy_user_session_path
|
||||
|
||||
-unless @landing_page
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ en:
|
|||
blog: "blog"
|
||||
login: "log in"
|
||||
code: "code"
|
||||
admin: "admin"
|
||||
application:
|
||||
powered_by: "POWERED BY DIASPORA*"
|
||||
whats_new: "what's new?"
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ Diaspora::Application.routes.draw do
|
|||
end
|
||||
|
||||
# generating a new user token (for devise)
|
||||
match 'users/generate_new_token' => 'users#generate_new_token'
|
||||
|
||||
# ActivityStreams routes
|
||||
scope "/activity_streams", :module => "activity_streams" do
|
||||
|
|
@ -75,6 +74,7 @@ Diaspora::Application.routes.draw do
|
|||
match 'user_search' => :user_search
|
||||
get 'admin_inviter' => :admin_inviter
|
||||
get 'add_invites' => :add_invites, :as => 'add_invites'
|
||||
get 'generate_new_token' => :generate_new_token, :as => 'new_auth_token'
|
||||
end
|
||||
|
||||
resource :profile
|
||||
|
|
|
|||
Loading…
Reference in a new issue