app/controllers/dashboard_controller.rb
# Generally, it is best to handle errors in every function for every case,
# however, given that this is a toy application and we will only throw API errors,
# it is ok to do this.
Generally, it is best to handle errors in every function for every case,
however, given that this is a toy application and we will only throw API errors,
it is ok to do this.
Generally it is best to handle errors in every function for every case however given that this is a toy application and we will only throw API errors it is ok to do this .
def handle_oauth
		if not params['code'] 
			flash[:error] = "There was an issue logging in with Dwolla. Try again later."
			redirect_to "/"
		else
			session[:oauth_token] = DwollaVars.Dwolla::OAuth.get_token(params['code'], DwollaVars.redirect)['access_token']
			session[:name] = DwollaVars.Dwolla::Users.me(session[:oauth_token])['Name']
			flash[:success] = "You have been successfully logged in!"
			redirect_to "/"
		end
	end
def handle_oauth if not params [ 'code' ] flash [ :error ] = "There was an issue logging in with Dwolla. Try again later." redirect_to "/" else session [ :oauth_token ] = DwollaVars . Dwolla :: OAuth . get_token ( params [ 'code' ] , DwollaVars . redirect ) [ 'access_token' ] session [ :name ] = DwollaVars . Dwolla :: Users . me ( session [ :oauth_token ] ) [ 'Name' ] flash [ :success ] = "You have been successfully logged in!" redirect_to "/" end end
Generally, it is best to handle errors in every function for every case,
however, given that this is a toy application and we will only throw API errors,
it is ok to do this.
Generally it is best to handle errors in every function for every case however given that this is a toy application and we will only throw API errors it is ok to do this .
# Set access token # Set name, for aesthetics. # Make user happy