リビジョン 16e57cae app/Controller/UsersController.php
| app/Controller/UsersController.php | ||
|---|---|---|
| 94 | 94 |
DS . 'users' . // コントローラ |
| 95 | 95 |
DS . 'activate' . // アクション |
| 96 | 96 |
DS . $this->User->id . // ユーザID |
| 97 |
DS . $this->User->getActivationHash(); // ハッシュ値
|
|
| 97 |
DS . $this->User->activationHash(); // ハッシュ値
|
|
| 98 | 98 |
$url = Router::url( $url, true); // ドメイン(+サブディレクトリ)を付与 |
| 99 | 99 |
$comment = $url; |
| 100 | 100 |
|
| 101 | 101 |
$Email = new CakeEmail(); |
| 102 | 102 |
$Email->charset('ISO-2022-JP');
|
| 103 | 103 |
$Email->emailFormat('text');
|
| 104 |
$Email->template('user_register');
|
|
| 104 |
$Email->template('register_mail');
|
|
| 105 | 105 |
$Email->viewVars(array('name'=>$name,'comment'=>$comment));
|
| 106 | 106 |
$Email->from( MAIL_FROM ); //MAIL_FROM:Config/const.phpにて定義 |
| 107 | 107 |
$Email->to($mail); |
| 108 |
$Email->subject('[PICT CODE]問い合わせ');
|
|
| 108 |
$Email->subject('【PictCode】仮登録が完了しました。');
|
|
| 109 | 109 |
$Email->send(); |
| 110 | 110 |
} |
| 111 | 111 |
|
| ... | ... | |
| 117 | 117 |
public function activate( $user_id = null, $in_hash = null) {
|
| 118 | 118 |
// UserモデルにIDをセット |
| 119 | 119 |
$this->User->id = $user_id; |
| 120 |
if ($this->User->exists() && $in_hash == $this->User->getActivationHash()) {
|
|
| 120 |
if ($this->User->exists() && $in_hash == $this->User->activationHash()) {
|
|
| 121 | 121 |
// 本登録に有効なURL |
| 122 | 122 |
// statusフィールドを1に更新 |
| 123 | 123 |
$this->User->saveField( 'status', 1); |
| 124 | 124 |
$this->Session->setFlash( 'Your account has been activated.'); |
| 125 |
|
|
| 126 |
$mail = $this->Session->read('register.User.email');
|
|
| 127 |
// exit; |
|
| 128 |
|
|
| 129 |
$Email = new CakeEmail(); |
|
| 130 |
$Email->charset('ISO-2022-JP');
|
|
| 131 |
$Email->emailFormat('text');
|
|
| 132 |
$Email->template('register_comp');
|
|
| 133 |
// $Email->viewVars(array('name'=>$name,'comment'=>$comment));
|
|
| 134 |
$Email->from( MAIL_FROM ); //MAIL_FROM:Config/const.phpにて定義 |
|
| 135 |
$Email->to($mail); |
|
| 136 |
$Email->subject('【PictCode】本登録が完了しました。');
|
|
| 137 |
$Email->send(); |
|
| 138 |
|
|
| 125 | 139 |
}else{
|
| 126 | 140 |
// 本登録に無効なURL |
| 127 | 141 |
$this->Session->setFlash( 'Invalid activation URL'); |
| 142 |
return $this->redirect(array('controller' => 'top', 'action' => 'index'));
|
|
| 128 | 143 |
} |
| 129 | 144 |
} |
| 130 | 145 |
|
| ... | ... | |
| 198 | 213 |
* @return void |
| 199 | 214 |
*/ |
| 200 | 215 |
public function login() {
|
| 201 |
<<<<<<< HEAD |
|
| 202 |
// if($this->Auth->user()){
|
|
| 203 |
// $this->redirect($this->Auth->redirectUrl()); |
|
| 204 |
// } |
|
| 205 |
======= |
|
| 206 |
//var_dump(Security::hash( "123", 'blowfish')); |
|
| 207 |
if($this->register->user()){
|
|
| 208 |
$this->redirect($this->Auth->redirectUrl()); |
|
| 216 |
if($this->Auth->user()){
|
|
| 217 |
// $this->redirect($this->Auth->redirectUrl()); |
|
| 218 |
$this->redirect('/users/login_top');
|
|
| 209 | 219 |
} |
| 210 |
>>>>>>> origin/develop |
|
| 211 | 220 |
if ($this->request->is('post')) {
|
| 212 |
<<<<<<< HEAD |
|
| 213 |
if ($this->register->login()) {
|
|
| 214 |
$this->redirect('/Users/login_top');
|
|
| 215 |
======= |
|
| 216 | 221 |
if ($this->Auth->login()) {
|
| 217 | 222 |
// $options = array('conditions' => array('User.email' => $this->Auth->user('User.email'),'User.status' => 1));
|
| 218 | 223 |
// $this->request->data = $this->User->find('first', $options);
|
| ... | ... | |
| 224 | 229 |
'key' => 'positive', |
| 225 | 230 |
)); |
| 226 | 231 |
} |
| 227 |
>>>>>>> 8fa10255c509b6b77d694b7366878172b605ee59 |
|
| 228 | 232 |
} else {
|
| 229 | 233 |
$this->Flash->loginerror('ニックネームか パスワードにまちがいが あるよ!', array(
|
| 230 | 234 |
'key' => 'positive', |
| ... | ... | |
| 240 | 244 |
* @return void |
| 241 | 245 |
*/ |
| 242 | 246 |
public function logout() {
|
| 243 |
$this->redirect($this->register->logout());
|
|
| 247 |
$this->redirect($this->Auth->logout());
|
|
| 244 | 248 |
} |
| 245 | 249 |
|
| 246 | 250 |
|
| ... | ... | |
| 292 | 296 |
// メール送信 |
| 293 | 297 |
$this->set('register',$this->Session->read('register'));
|
| 294 | 298 |
$mail = $this->Session->read('register.User.email');
|
| 295 |
$options = array('conditions' => array('User.email' => $mail));
|
|
| 299 |
$options = array('conditions' => array('User.email' => $mail, 'User.status' => 1));
|
|
| 296 | 300 |
$user = $this->User->find('first', $options);
|
| 297 | 301 |
$name = $user['User']['login_id']; |
| 298 | 302 |
|
| ... | ... | |
| 301 | 305 |
DS . 'users' . // コントローラ |
| 302 | 306 |
DS . 'newpwd' . // アクション |
| 303 | 307 |
DS . $user['User']['id'] . // ユーザID |
| 304 |
DS . $this->User->getActivationHash(); // ハッシュ値 |
|
| 308 |
DS . $this->User->getActivationHash($user['User']['id']); // ハッシュ値
|
|
| 305 | 309 |
$url = Router::url( $url, true); // ドメイン(+サブディレクトリ)を付与 |
| 306 | 310 |
$comment = $url; |
| 307 | 311 |
$Email = new CakeEmail(); |
| ... | ... | |
| 311 | 315 |
$Email->viewVars(array('name'=>$name,'comment'=>$comment));
|
| 312 | 316 |
$Email->from( MAIL_FROM ); //MAIL_FROM:Config/const.phpにて定義 |
| 313 | 317 |
$Email->to($mail); |
| 314 |
$Email->subject('[PICT CODE]問い合わせ');
|
|
| 318 |
$Email->subject('【PictCode】パスワードの再発行を受け付けました。');
|
|
| 315 | 319 |
$Email->send(); |
| 316 | 320 |
} |
| 317 | 321 |
|
| ... | ... | |
| 327 | 331 |
|
| 328 | 332 |
// UserモデルにIDをセット |
| 329 | 333 |
$this->User->id = $user_id; |
| 330 |
if ($this->User->exists() && $in_hash == $this->User->getActivationHash()) {
|
|
| 331 |
$this->Session->setFlash( '無効なURLです'); |
|
| 332 |
return $this->redirect(array('controller' => 'top', 'action' => 'index'));
|
|
| 333 |
|
|
| 334 |
}else{
|
|
| 334 |
if ($this->User->exists() && $in_hash == $this->User->activationHash()) {
|
|
| 335 |
//idとハッシュ値が正規の場合、パスワード変更画面を表示 |
|
| 335 | 336 |
if ($this->request->is(array('post', 'put'))) {
|
| 336 | 337 |
|
| 337 | 338 |
$this->set('user', $this->request->data);
|
| 338 | 339 |
if ($this->User->save($this->request->data)) {
|
| 339 |
return $this->redirect(array('action' => 'reset_pwd_comp_mail'));
|
|
| 340 |
return $this->redirect(array('action' => 'reset_pwd_comp_mail',$user_id));
|
|
| 340 | 341 |
} |
| 341 | 342 |
} else {
|
| 342 | 343 |
$options = array('conditions' => array('User.id' => $user_id,'User.status' => 1));
|
| 343 | 344 |
$this->request->data = $this->User->find('first', $options);
|
| 344 | 345 |
$this->set('user', $this->request->data);
|
| 345 |
// var_dump($this->request->data); |
|
| 346 |
// exit; |
|
| 347 | 346 |
} |
| 348 |
} |
|
| 347 |
}else{
|
|
| 348 |
//idとハッシュ値が不正の場合、トップページにリダイレクト |
|
| 349 |
$this->Session->setFlash( '無効なURLです'); |
|
| 350 |
return $this->redirect(array('controller' => 'top', 'action' => 'index'));
|
|
| 349 | 351 |
|
| 350 |
// $options = array('conditions' => array('User.id' => $user_id,'User.status' => 1));
|
|
| 351 |
// // $this->request->data = $this->set('user',$this->User->find('first', $options));
|
|
| 352 |
// $this->set('user',$this->User->find('first', $options));
|
|
| 353 |
// // $this->set('user', $this->request->data);
|
|
| 354 |
|
|
| 355 |
|
|
| 356 |
// // if ($this->User->exists() && $in_hash == $this->User->getActivationHash()) {
|
|
| 357 |
// // var_dump($this->request->data); |
|
| 358 |
// // exit; |
|
| 359 |
// if ($this->request->is(array('post', 'put'))) {
|
|
| 360 |
// // if($this->User->validates()){
|
|
| 361 |
|
|
| 362 |
// $this->User->save($this->request->data); |
|
| 363 |
// $this->redirect(array('action'=>'reset_pwd_comp_mail'));
|
|
| 364 |
// // } else {
|
|
| 365 |
// // $this->Flash->loginerror('パスワードが一致しません。誤りがないかもう一度ご確認の上、正確にご入力ください。', array(
|
|
| 366 |
// // 'key' => 'positive', |
|
| 367 |
// // )); |
|
| 368 |
// // } |
|
| 369 |
// // } else {
|
|
| 370 |
// // $options = array('conditions' => array('User.id' => $user_id,'User.status' => 1));
|
|
| 371 |
// // $this->request->data = $this->set('user',$this->User->find('first', $options));
|
|
| 372 |
// // // $this->set('user', $this->request->data);
|
|
| 373 |
// // $this->Session->setFlash( '無効なURLですaaa'); |
|
| 374 |
// // } |
|
| 375 |
|
|
| 376 |
|
|
| 377 |
// }else{
|
|
| 378 |
// // 本登録に無効なURL |
|
| 379 |
// $this->Session->setFlash( '無効なURLです'); |
|
| 380 |
// } |
|
| 352 |
} |
|
| 381 | 353 |
} |
| 382 | 354 |
|
| 383 | 355 |
/** |
| 384 | 356 |
* |
| 385 | 357 |
*/ |
| 386 |
public function reset_pwd_comp_mail() {
|
|
| 387 |
// if (!empty( $this->data)){
|
|
| 388 |
// 保存 |
|
| 389 |
$this->User->validate = $this->User->new_pwd_validate; |
|
| 390 |
if( $this->User->save($this->request->data('user'))){
|
|
| 391 |
// メール送信 |
|
| 392 |
$this->set('register',$this->Session->read('register'));
|
|
| 358 |
public function reset_pwd_comp_mail($user_id = null) {
|
|
| 359 |
// $options = array('conditions' => array('User.' . $this->User->primaryKey => $user_id));
|
|
| 360 |
// $this->request->data = $this->User->find('first', $options);
|
|
| 361 |
// //バリデーションを無効にして保存 |
|
| 362 |
// $this->User->validate = $this->User->reset_pwd_comp_mail_validate; |
|
| 363 |
|
|
| 364 |
// if( $this->User->save($this->request->data)){
|
|
| 365 |
// var_dump($this->request->data['User']); |
|
| 366 |
// exit; |
|
| 367 |
if( !isset($this->request->data['User'])){
|
|
| 368 |
// $this->User->save($this->request->data,false); |
|
| 369 |
// メール送信 |
|
| 393 | 370 |
$mail = $this->Session->read('register.User.email');
|
| 394 |
// exit; |
|
| 395 |
$options = array('conditions' => array('User.email' => $mail));
|
|
| 396 |
$user = $this->User->find('first', $options);
|
|
| 397 |
$name = $user['User']['login_id']; |
|
| 398 |
|
|
| 399 |
// ユーザアクティベート(本登録)用URLの作成 DSはスラッシュの意味 |
|
| 400 |
// $url = |
|
| 401 |
// DS . 'users' . // コントローラ |
|
| 402 |
// DS . 'newpwd' . // アクション |
|
| 403 |
// DS . $user['User']['id'] . // ユーザID |
|
| 404 |
// DS . $this->User->getActivationHash(); // ハッシュ値 |
|
| 405 |
// $url = Router::url( $url, true); // ドメイン(+サブディレクトリ)を付与 |
|
| 406 |
$comment = "本文本文本文本文本文本文本文本文"; |
|
| 371 |
|
|
| 407 | 372 |
$Email = new CakeEmail(); |
| 408 | 373 |
$Email->charset('ISO-2022-JP');
|
| 409 | 374 |
$Email->emailFormat('text');
|
| 410 | 375 |
$Email->template('comp_reset_pwd');
|
| 411 |
$Email->viewVars(array('name'=>$name,'comment'=>$comment));
|
|
| 376 |
// $Email->viewVars(array('name'=>$name,'comment'=>$comment));
|
|
| 412 | 377 |
$Email->from( MAIL_FROM ); //MAIL_FROM:Config/const.phpにて定義 |
| 413 | 378 |
$Email->to($mail); |
| 414 |
$Email->subject('[PICT CODE]問い合わせ');
|
|
| 379 |
$Email->subject('【PictCode】パスワードの再設定が完了しました。');
|
|
| 415 | 380 |
$Email->send(); |
| 416 |
} |
|
| 417 |
// } |
|
| 418 |
// }else{
|
|
| 419 |
// exit; |
|
| 420 |
// } |
|
| 421 |
debug($this->User->validationErrors); |
|
| 381 |
} |
|
| 382 |
else{
|
|
| 383 |
$options = array('conditions' => array('User.' . $this->User->primaryKey => $user_id));
|
|
| 384 |
$this->request->data = $this->User->find('first', $options);
|
|
| 385 |
//バリデーションを無効にして保存 |
|
| 386 |
// $this->User->validate = $this->User->reset_pwd_comp_mail_validate; |
|
| 387 |
$this->User->save($this->request->data,false); |
|
| 388 |
} |
|
| 389 |
|
|
| 422 | 390 |
} |
| 423 | 391 |
|
| 424 | 392 |
|
他の形式にエクスポート: Unified diff