Move auth_token to users controller
This token is only used for the chat, it isn't an official API.
This commit is contained in:
parent
368e6d9ef5
commit
16cd4752cb
4 changed files with 7 additions and 23 deletions
|
|
@ -12,7 +12,7 @@
|
||||||
// initialize jsxc xmpp client
|
// initialize jsxc xmpp client
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if (app.currentUser.authenticated()) {
|
if (app.currentUser.authenticated()) {
|
||||||
$.post('api/v1/tokens', null, function(data) {
|
$.post("/user/auth_token", null, function(data) {
|
||||||
if (jsxc && data['token']) {
|
if (jsxc && data['token']) {
|
||||||
var jid = app.currentUser.get('diaspora_id');
|
var jid = app.currentUser.get('diaspora_id');
|
||||||
jsxc.init({
|
jsxc.init({
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
class Api::V1::TokensController < ApplicationController
|
|
||||||
skip_before_filter :verify_authenticity_token
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
|
|
||||||
respond_to :json
|
|
||||||
|
|
||||||
def create
|
|
||||||
current_user.ensure_authentication_token!
|
|
||||||
render :status => 200, :json => { :token => current_user.authentication_token }
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
current_user.reset_authentication_token!
|
|
||||||
render :json => true, :status => 200
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -128,6 +128,11 @@ class UsersController < ApplicationController
|
||||||
redirect_to edit_user_path
|
redirect_to edit_user_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def auth_token
|
||||||
|
current_user.ensure_authentication_token!
|
||||||
|
render status: 200, json: {token: current_user.authentication_token}
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# rubocop:disable Metrics/MethodLength
|
# rubocop:disable Metrics/MethodLength
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ Diaspora::Application.routes.draw do
|
||||||
get :download_profile
|
get :download_profile
|
||||||
post :export_photos
|
post :export_photos
|
||||||
get :download_photos
|
get :download_photos
|
||||||
|
post :auth_token
|
||||||
end
|
end
|
||||||
|
|
||||||
controller :users do
|
controller :users do
|
||||||
|
|
@ -184,12 +185,6 @@ Diaspora::Application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :api do
|
|
||||||
namespace :v1 do
|
|
||||||
resources :tokens, :only => [:create, :destroy]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight'
|
get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight'
|
||||||
# Mobile site
|
# Mobile site
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue