Sha256: 2a2babb7417c9ebc65ef63bbc636151966ed9e6a3d1714928cd4251ba9b62760

Contents?: true

Size: 1.2 KB

Versions: 234

Compression:

Stored size: 1.2 KB

Contents

module Caboose
  class MyAccountController < Caboose::ApplicationController
            
    # GET /my-account
    def index
      return if !verify_logged_in
      @user = logged_in_user      
    end
    
    # PUT /my-account
    def update  
      return if !logged_in?
      
      resp = StdClass.new     
      user = logged_in_user
    
      save = true
      params.each do |name,value|
        case name
    	  	when "first_name" then user.first_name  = value
    	  	when "last_name"  then user.last_name   = value
    	  	when "username"   then user.username    = value
    	  	when "email"      then user.email       = value
    	  	when "phone"      then user.phone       = value
    	  	when "password"			  
    	  	  confirm = params[:confirm]
    	  		if value != confirm			
    	  		  resp.error = "Passwords do not match.";
    	  		  save = false
    	  		elsif value.length < 8
    	  		  resp.error = "Passwords must be at least 8 characters.";
    	  		  save = false
    	  		else
    	  		  user.password = Digest::SHA1.hexdigest(Caboose::salt + value)
    	  		end    	  	    		  
    	  end
    	end
    	
    	resp.success = save && user.save
    	render :json => resp
    end        
  end
end

Version data entries

234 entries across 234 versions & 1 rubygems

Version Path
caboose-cms-0.7.85 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.84 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.83 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.82 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.81 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.80 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.79 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.78 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.77 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.76 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.75 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.74 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.73 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.72 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.71 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.70 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.69 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.68 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.67 app/controllers/caboose/my_account_controller.rb
caboose-cms-0.7.66 app/controllers/caboose/my_account_controller.rb