-1
cakePHPを使用して、私はこの小さなソースコードについてのあなたの見解を持っていたいと思います。 sha1()
は別のハッシュスクリプトで削除されます。私は最適化することができますが、どのように見つけることができる?私のログイン機能は安全ですか?それを改善する方法を知らない
ありがとう
クラスがUserControllerは、コントローラー{
function account($Req){
if(isset($Req->post->login)){
$login = addslashes($Req->post->login);
$password = sha1(addslashes($Req->post->password));
$pass_confirm = sha1(addslashes($Req->post->pass_confirm));
$email = addslashes($Req->post->email);
$signature = addslashes($Req->post->signature);
if(empty($login) || empty($email)){
$this->Session->setFlash("You hav to complete each fiedls", "error");
$this->Request->redirect(SITE . "users/account");
}
elseif($pass_confirm != $password) {
$this->Session->setFlash("You gave two differents password", "error");
$Req->redirect(SITE . "users/account");
}
$this->loadModel("Users");
$dispoLogin = $this->Users->findCount(array(
"login" => $login
));
if($dispoLogin === 0){
$this->Session->setFlash("The login is already use by someone else", "error");
$this->Request->redirect(SITE . "users/account");
}
$dispoEmail = $this->Users->findCount(array(
"email" => $email
));
if($dispoEmail === 0){
$this->Session->setFlash("Email adress already use by someone else", "error");
$this->Request->redirect(SITE . "users/account");
}
if(empty($password)){
$q = $this->Users->findFirst(array(
"fields" => "password",
"conditions" => array(
"id" => $this->User->id
)
));
$password = sha1($q->password);
}
$this->Users->save(array(
"id" => $this->User->id,
"login" => $login,
"password" => $password,
"email" => $email,
"signature" => $signature
));
$this->user->setData(array(
"login" => $login,
"password" => $password,
"email" => $email,
"signature" => $signature
));
$this->Session->setFlash("Your profile page is updated");
$this->Request->redirect(SITE);
}
}
これは、プログラマーズ・スタック・エクスチェンジ・コムに適しています。 – Bojangles
@JamWafflesそこにも適合しません。 http://codereview.stackexchange.com – Mob
@Mob Darn it! 2つが混ざった。 – Bojangles