Skip to content

Commit

Permalink
Corrected a bug with login/password nil
Browse files Browse the repository at this point in the history
  • Loading branch information
s2j1h committed Oct 16, 2010
1 parent 11a6c57 commit 2690147
Show file tree
Hide file tree
Showing 4 changed files with 861 additions and 3 deletions.
23 changes: 21 additions & 2 deletions app/controllers/identities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,25 @@ def edit
# POST /identities
# POST /identities.xml
def create
@identity = current_user.identities.new(params[:identity])
@identity = current_user.identities.new(params[:identity])
puts "toto:" + @identity.login + ":"
if @identity.login.empty?
puts "login vide"
else
puts "login plein"
end
#1 check secretkey
digested_key = hash_secretkey(params[:secretkey])
if current_user.secretkey != digested_key
respond_to do |format|
flash[:error] = 'Sorry but your secret key doesn\'t match!'
format.html { render :action => "new" }
end
elsif @identity.login.empty? || @identity.password.empty?
respond_to do |format|
flash[:error] = 'Sorry but you need to type a login and a password'
format.html { render :action => "new" }
end
else
#2 encrypt login/pwd
@identity.login = encrypt_identity(digested_key,@identity.login)
Expand Down Expand Up @@ -83,7 +94,15 @@ def update
flash[:error] = 'Sorry but your secret key doesn\'t match!'
format.html { render :action => "edit" }
end
else
elsif params[:identity][:login].blank? or params[:identity][:password].blank?
@identity.login = params[:identity][:login]
@identity.password = params[:identity][:password]
respond_to do |format|
flash[:error] = 'Sorry but you need to type a login and a password'
format.html { render :action => "edit" }
end

else
#2 encrypt login/pwd
params[:identity][:login] = encrypt_identity(digested_key,params[:identity][:login])
params[:identity][:password] = encrypt_identity(digested_key,params[:identity][:password])
Expand Down
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
#RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Expand Down
Binary file modified db/development.sqlite3
Binary file not shown.

0 comments on commit 2690147

Please sign in to comment.