diff --git a/tracks/app/controllers/backend_controller.rb b/tracks/app/controllers/backend_controller.rb index 8bb073fa..a949b3db 100644 --- a/tracks/app/controllers/backend_controller.rb +++ b/tracks/app/controllers/backend_controller.rb @@ -6,14 +6,14 @@ class BackendController < ApplicationController def new_todo(username, token, context_id, description) - check_token_against_user_word(username, token) + check_token(username, token) check_context_belongs_to_user(context_id) item = create_todo(description, context_id) item.id end def new_rich_todo(username, token, default_context_id, description) - check_token_against_user_word(username,token) + check_token(username,token) description,context = split_by_char('@',description) description,project = split_by_char('>',description) if(!context.nil? && project.nil?) @@ -44,23 +44,23 @@ class BackendController < ApplicationController end def list_contexts(username, token) - check_token_against_user_word(username, token) + check_token(username, token) @user.contexts end def list_projects(username, token) - check_token_against_user_word(username, token) + check_token(username, token) @user.projects end private - # Check whether the token in the URL matches the word in the User's table - def check_token_against_user_word(username, token) + # Check whether the token in the URL matches the token in the User's table + def check_token(username, token) @user = User.find_by_login( username ) - unless (token == @user.word) + unless (token == @user.token) raise(InvalidToken, "Sorry, you don't have permission to perform this action.") end end diff --git a/tracks/app/controllers/users_controller.rb b/tracks/app/controllers/users_controller.rb index 3821815b..09222959 100644 --- a/tracks/app/controllers/users_controller.rb +++ b/tracks/app/controllers/users_controller.rb @@ -220,7 +220,7 @@ class UsersController < ApplicationController def refresh_token - @user.crypt_word + @user.crypt_token @user.save notify :notice, "New token successfully generated" redirect_to :controller => 'preferences', :action => 'index' diff --git a/tracks/app/helpers/feedlist_helper.rb b/tracks/app/helpers/feedlist_helper.rb index 562e6521..a8b34bb1 100644 --- a/tracks/app/helpers/feedlist_helper.rb +++ b/tracks/app/helpers/feedlist_helper.rb @@ -2,19 +2,19 @@ module FeedlistHelper def rss_formatted_link(options = {}) image_tag = image_tag("feed-icon.png", :size => "16X16", :border => 0, :class => "rss-icon") - linkoptions = { :token => @user.word, :format => 'rss' } + linkoptions = { :token => @user.token, :format => 'rss' } linkoptions.merge!(options) link_to(image_tag, linkoptions, :title => "RSS feed") end def text_formatted_link(options = {}) - linkoptions = { :token => @user.word, :format => 'txt' } + linkoptions = { :token => @user.token, :format => 'txt' } linkoptions.merge!(options) link_to('TXT', linkoptions, :title => "Plain text feed" ) end def ical_formatted_link(options = {}) - linkoptions = { :token => @user.word, :format => 'ics' } + linkoptions = { :token => @user.token, :format => 'ics' } linkoptions.merge!(options) link_to('iCal', linkoptions, :title => "iCal feed" ) end diff --git a/tracks/app/models/user.rb b/tracks/app/models/user.rb index 7a3ab1f5..947aa5c5 100644 --- a/tracks/app/models/user.rb +++ b/tracks/app/models/user.rb @@ -92,7 +92,7 @@ class User < ActiveRecord::Base validates_uniqueness_of :login, :on => :create validates_presence_of :open_id_url, :if => Proc.new{|user| user.auth_type == 'open_id'} - before_create :crypt_password, :crypt_word + before_create :crypt_password, :crypt_token before_update :crypt_password def validate @@ -174,8 +174,8 @@ protected Digest::SHA1.hexdigest("#{Tracks::Config.salt}--#{pass}--") end - def crypt_word - write_attribute("word", self.class.sha1(login + Time.now.to_i.to_s + rand.to_s)) + def crypt_token + write_attribute("token", self.class.sha1(login + Time.now.to_i.to_s + rand.to_s)) end def crypt_password diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index 64240da3..b7183a2e 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -17,7 +17,7 @@ <%= javascript_include_tag "protoload" %> - <%= auto_discovery_link_tag(:rss,{:controller => "feed", :action => "na_feed", :name => "#{@user.login}", :token => "#{@user.word}"}, {:title => "RSS feed of next actions"}) %> + <%= auto_discovery_link_tag(:rss,{:controller => "feed", :action => "na_feed", :name => "#{@user.login}", :token => "#{@user.token}"}, {:title => "RSS feed of next actions"}) %>