Browse files

moved password reset and update to new api

  • Loading branch information...
1 parent b4d4738 commit 57ea171d8a3dbabf64e41111ebada5afb09cde04 @jeffdonthemic jeffdonthemic committed Oct 1, 2012
View
16 app/controllers/accounts_controller.rb
@@ -132,11 +132,11 @@ def public_profile
# Action to change the password of logged user (not activated)
def password
if params[:reset]
- results = Password.reset(current_user.username)
- if results['Success'].eql?('true')
- redirect_to password_reset_url, :notice => results["Message"]
+ results = Account.reset_password(current_user.username)
+ if results['success'].eql?('true')
+ redirect_to password_reset_url, :notice => results["message"]
else
- flash.now[:notice] = results["Message"]
+ flash.now[:notice] = results["message"]
end
end
@page_title = "Change Your Password"
@@ -151,14 +151,14 @@ def password_reset
if params[:reset_password_account_form]
@reset_form = ResetPasswordAccountForm.new(params[:reset_password_account_form])
if @reset_form.valid?
- results = Password.update(current_user.username, params[:reset_password_account_form][:passcode],
+ results = Account.update_password(current_user.username, params[:reset_password_account_form][:passcode],
params[:reset_password_account_form][:password])
- if results["Success"].eql?('false')
- flash.now[:error] = results["Message"]
+ if results["success"].eql?('false')
+ flash.now[:error] = results["message"]
else
current_user.password = params[:reset_password_account_form][:password]
current_user.save
- flash.now[:notice] = results["Message"]
+ flash.now[:notice] = results["message"]
end
else
# display the validation messages
View
2 app/controllers/content_controller.rb
@@ -1,5 +1,3 @@
-require 'faqs'
-require 'webpages'
require 'sfdc_connection'
class ContentController < ApplicationController
View
10 app/controllers/sessions_controller.rb
@@ -302,11 +302,11 @@ def public_forgot_password
def public_forgot_password_send
if params[:form_forgot_password]
results = Account.reset_password(params[:form_forgot_password][:username])
- if results['Success'].eql?('true')
- flash[:notice] = results["Message"]
+ if results['success'].eql?('true')
+ flash[:notice] = results["message"]
redirect_to reset_password_url
else
- flash[:error] = results["Message"]
+ flash[:error] = results["message"]
redirect_to forgot_password_url
end
end
@@ -323,8 +323,8 @@ def public_reset_password_submit
@reset_form = ResetPasswordForm.new(params[:reset_password_form])
if @reset_form.valid?
Services.activate_user(current_access_token, params[:reset_password_form][:username])
- results = Password.update(params[:reset_password_form][:username], params[:reset_password_form][:passcode], params[:reset_password_form][:password])
- flash.now[:warning] = results["Message"]
+ results = Account.update_password(params[:reset_password_form][:username], params[:reset_password_form][:passcode], params[:reset_password_form][:password])
+ flash.now[:warning] = results["message"]
render :action => 'public_reset_password'
else
# not valid. display signup for with errors
View
BIN db/development.sqlite3
Binary file not shown.
View
17 lib/account.rb
@@ -0,0 +1,17 @@
+class Account < Cloudspokes
+
+ require 'cloud_spokes'
+
+ def self.reset_password(name)
+ set_api_header_key
+ request_url = ENV['CS_API_URL'] + "/accounts/reset_password/#{esc name}"
+ get(request_url)['response']
+ end
+
+ # moved to new api
+ def self.update_password(membername, passcode, newpassword)
+ set_api_header_key
+ put(ENV['CS_API_URL'] + "/accounts/update_password/#{esc membername}?passcode=#{esc passcode}&new_password=#{esc newpassword}")['response']
+ end
+
+end
View
2 lib/cloud_spokes.rb
@@ -11,7 +11,7 @@ class Cloudspokes
include HTTParty
format :json
- AvailableObjects = ["challenges","members","recommendations","participants","faqs","webpages","payments","categories","terms_of_service"]
+ AvailableObjects = ["challenges","members","participants","faqs","webpages","payments","categories","terms_of_service"]
SFDC_URL = ENV['SFDC_INSTANCE_URL']+'/services/data/v20.0/sobjects/'
headers 'Content-Type' => 'application/json'
View
18 lib/password.rb
@@ -1,18 +0,0 @@
-require 'cloud_spokes'
-require 'cgi'
-
-class Password < Cloudspokes
-
- # sends the reset email --- moved to new api
- def self.reset(name)
- request_url = ENV['SFDC_REST_API_URL'] + "/password/reset?username=#{name}"
- post(request_url,:body => {})
- end
-
- # moved to new api
- def self.update(name, passcode, newpassword)
- request_url = ENV['SFDC_REST_API_URL'] + "/password/reset?username=#{name}&passcode=#{passcode}&newpassword=#{CGI.escape(newpassword)}"
- put(request_url,:body => {})
- end
-
-end

0 comments on commit 57ea171

Please sign in to comment.