Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

moved password reset and update to new api

  • Loading branch information...
commit 57ea171d8a3dbabf64e41111ebada5afb09cde04 1 parent b4d4738
Jeff Douglas jeffdonthemic authored
16 app/controllers/accounts_controller.rb
@@ -132,11 +132,11 @@ def public_profile
132 132 # Action to change the password of logged user (not activated)
133 133 def password
134 134 if params[:reset]
135   - results = Password.reset(current_user.username)
136   - if results['Success'].eql?('true')
137   - redirect_to password_reset_url, :notice => results["Message"]
  135 + results = Account.reset_password(current_user.username)
  136 + if results['success'].eql?('true')
  137 + redirect_to password_reset_url, :notice => results["message"]
138 138 else
139   - flash.now[:notice] = results["Message"]
  139 + flash.now[:notice] = results["message"]
140 140 end
141 141 end
142 142 @page_title = "Change Your Password"
@@ -151,14 +151,14 @@ def password_reset
151 151 if params[:reset_password_account_form]
152 152 @reset_form = ResetPasswordAccountForm.new(params[:reset_password_account_form])
153 153 if @reset_form.valid?
154   - results = Password.update(current_user.username, params[:reset_password_account_form][:passcode],
  154 + results = Account.update_password(current_user.username, params[:reset_password_account_form][:passcode],
155 155 params[:reset_password_account_form][:password])
156   - if results["Success"].eql?('false')
157   - flash.now[:error] = results["Message"]
  156 + if results["success"].eql?('false')
  157 + flash.now[:error] = results["message"]
158 158 else
159 159 current_user.password = params[:reset_password_account_form][:password]
160 160 current_user.save
161   - flash.now[:notice] = results["Message"]
  161 + flash.now[:notice] = results["message"]
162 162 end
163 163 else
164 164 # display the validation messages
2  app/controllers/content_controller.rb
... ... @@ -1,5 +1,3 @@
1   -require 'faqs'
2   -require 'webpages'
3 1 require 'sfdc_connection'
4 2
5 3 class ContentController < ApplicationController
10 app/controllers/sessions_controller.rb
@@ -302,11 +302,11 @@ def public_forgot_password
302 302 def public_forgot_password_send
303 303 if params[:form_forgot_password]
304 304 results = Account.reset_password(params[:form_forgot_password][:username])
305   - if results['Success'].eql?('true')
306   - flash[:notice] = results["Message"]
  305 + if results['success'].eql?('true')
  306 + flash[:notice] = results["message"]
307 307 redirect_to reset_password_url
308 308 else
309   - flash[:error] = results["Message"]
  309 + flash[:error] = results["message"]
310 310 redirect_to forgot_password_url
311 311 end
312 312 end
@@ -323,8 +323,8 @@ def public_reset_password_submit
323 323 @reset_form = ResetPasswordForm.new(params[:reset_password_form])
324 324 if @reset_form.valid?
325 325 Services.activate_user(current_access_token, params[:reset_password_form][:username])
326   - results = Password.update(params[:reset_password_form][:username], params[:reset_password_form][:passcode], params[:reset_password_form][:password])
327   - flash.now[:warning] = results["Message"]
  326 + results = Account.update_password(params[:reset_password_form][:username], params[:reset_password_form][:passcode], params[:reset_password_form][:password])
  327 + flash.now[:warning] = results["message"]
328 328 render :action => 'public_reset_password'
329 329 else
330 330 # not valid. display signup for with errors
BIN  db/development.sqlite3
Binary file not shown
17 lib/account.rb
... ... @@ -0,0 +1,17 @@
  1 +class Account < Cloudspokes
  2 +
  3 + require 'cloud_spokes'
  4 +
  5 + def self.reset_password(name)
  6 + set_api_header_key
  7 + request_url = ENV['CS_API_URL'] + "/accounts/reset_password/#{esc name}"
  8 + get(request_url)['response']
  9 + end
  10 +
  11 + # moved to new api
  12 + def self.update_password(membername, passcode, newpassword)
  13 + set_api_header_key
  14 + put(ENV['CS_API_URL'] + "/accounts/update_password/#{esc membername}?passcode=#{esc passcode}&new_password=#{esc newpassword}")['response']
  15 + end
  16 +
  17 +end
2  lib/cloud_spokes.rb
@@ -11,7 +11,7 @@ class Cloudspokes
11 11 include HTTParty
12 12 format :json
13 13
14   - AvailableObjects = ["challenges","members","recommendations","participants","faqs","webpages","payments","categories","terms_of_service"]
  14 + AvailableObjects = ["challenges","members","participants","faqs","webpages","payments","categories","terms_of_service"]
15 15 SFDC_URL = ENV['SFDC_INSTANCE_URL']+'/services/data/v20.0/sobjects/'
16 16
17 17 headers 'Content-Type' => 'application/json'
18 lib/password.rb
... ... @@ -1,18 +0,0 @@
1   -require 'cloud_spokes'
2   -require 'cgi'
3   -
4   -class Password < Cloudspokes
5   -
6   - # sends the reset email --- moved to new api
7   - def self.reset(name)
8   - request_url = ENV['SFDC_REST_API_URL'] + "/password/reset?username=#{name}"
9   - post(request_url,:body => {})
10   - end
11   -
12   - # moved to new api
13   - def self.update(name, passcode, newpassword)
14   - request_url = ENV['SFDC_REST_API_URL'] + "/password/reset?username=#{name}&passcode=#{passcode}&newpassword=#{CGI.escape(newpassword)}"
15   - put(request_url,:body => {})
16   - end
17   -
18   -end

0 comments on commit 57ea171

Please sign in to comment.
Something went wrong with that request. Please try again.