Ejemplo n.º 1
0
 public function sendActivationMail($user)
 {
     $activation = new Activation();
     $activation->setSfGuardUser($user);
     $key = sha1($user->getUsername() . time());
     $activation->setActivationKey($key);
     $activation->save();
     $message = $this->getMailer()->composeAndSend('*****@*****.**', $user->getEmailAddress(), 'Please confirm your registration!', 'Hello ' . $user->getName() . ',
     Please click on the following link to complete your registration:
     ' . $this->generateUrl('register_activation', array('activation_key' => $activation->getActivationKey()), true) . '
     We hope you will have fun!');
     $this->getUser()->setFlash('notice', 'Un mail de confirmation vous a été envoyé !');
     $this->redirect('@homepage');
 }
 /**
  * 动作:注册
  * @return Response
  */
 public function postSignup()
 {
     // 获取所有表单数据.
     $data = Input::all();
     // 创建验证规则
     $rules = array('email' => 'required|email|unique:users', 'password' => 'required|alpha_dash|between:6,16|confirmed');
     // 自定义验证消息
     $messages = array('email.required' => '请输入邮箱地址。', 'email.email' => '请输入正确的邮箱地址。', 'email.unique' => '此邮箱已被使用。', 'password.required' => '请输入密码。', 'password.alpha_dash' => '密码格式不正确。', 'password.between' => '密码长度请保持在:min到:max位之间。', 'password.confirmed' => '两次输入的密码不一致。');
     // 开始验证
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         // 验证成功,添加用户
         $user = new User();
         $user->email = Input::get('email');
         $user->password = Input::get('password');
         if ($user->save()) {
             // 添加成功
             // 生成激活码
             $activation = new Activation();
             $activation->email = $user->email;
             $activation->token = str_random(40);
             $activation->save();
             // 发送激活邮件
             $with = array('activationCode' => $activation->token);
             Mail::send('authority.email.activation', $with, function ($message) use($user) {
                 $message->to($user->email)->subject('Simple - Blog 账号激活邮件');
                 // 标题
             });
             // 跳转到注册成功页面,提示用户激活
             return Redirect::route('signupSuccess', $user->email);
         } else {
             // 添加失败
             return Redirect::back()->withInput()->withErrors(array('add' => '注册失败。'));
         }
     } else {
         // 验证失败,跳回
         return Redirect::back()->withInput()->withErrors($validator);
     }
 }
Ejemplo n.º 3
0
 /**
  * Store a newly created user in storage.
  *
  * @return Response
  */
 public function store()
 {
     /* Fetching inputs and creating model */
     $user = new User();
     $id = mt_rand();
     Input::merge(['profile_url' => $id, 'fresh' => '1']);
     if (Input::get('type') == 'charity') {
         Input::merge(['approved' => '1']);
     }
     if ($user->save()) {
         /* Generate activation code */
         $activation = new Activation();
         $activation->generate($user);
         $activation->save();
         /* Queueing email */
         $m = new Mailer();
         $m->send($user, 'emails.activation', array('code' => $activation->code), array('subject' => 'Music Equity Account Activation', 'from' => '*****@*****.**'));
         return Response::json(array('success' => true));
     } else {
         return Response::json($user->errors());
     }
 }
Ejemplo n.º 4
0
			if (!doEmail($user->username, $password, $user->email)) {
				throw new Exception('Could not send the activation email. Please contact an admin on the forum, or by email');
			}
			
			header('Location: index.php?e=6');
			exit;		 
			
		}
		else {
			// need to check the Activatoin table.
			$a = new Activation();
			$a->getByEmail($email);
			if ($a->id and !$a->success) {
				// Good
				$a->password = md5($password);
				$a->save();
				
				if (!doEmail($a->username, $password, $a->email)) {
					throw new Exception('Could not send the activation email. Please contact an admin on the forum, or by email');
				}
				
				header('Location: index.php?e=6');
				exit;		
			}
			else {
				throw new Exception('That email address does not exists');			
			}
		}
		
		
	} //if 
 /**
  * Action: Signup
  * @return Response
  */
 public function postSignup()
 {
     // Get all form data.
     $data = Input::all();
     // Create validation rules
     $rules = array('email' => 'required|email|unique:users', 'password' => 'required|alpha_dash|between:6,16|confirmed');
     // Custom validation message
     $messages = array('email.required' => '请输入邮箱地址。', 'email.email' => '请输入正确的邮箱地址。', 'email.unique' => '此邮箱已被使用。', 'password.required' => '请输入密码。', 'password.alpha_dash' => '密码格式不正确。', 'password.between' => '密码长度请保持在:min到:max位之间。', 'password.confirmed' => '两次输入的密码不一致。');
     // Begin verification
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         // Verification success,add user
         $user = new User();
         $user->email = Input::get('email');
         $user->password = Input::get('password');
         if ($user->save()) {
             // Add user success
             // Generate activation code
             $activation = new Activation();
             $activation->email = $user->email;
             $activation->token = str_random(40);
             $activation->save();
             // Send activation mail
             $with = array('activationCode' => $activation->token);
             Mail::later(10, 'authority.email.activation', $with, function ($message) use($user) {
                 $message->to($user->email)->subject('时光碎片 账号激活邮件');
                 // Subject
             });
             // Redirect to a registration page, prompts user to activate
             return Redirect::route('signupSuccess', $user->email);
         } else {
             // Add user fail
             return Redirect::back()->withInput()->withErrors(array('add' => '注册失败。'));
         }
     } else {
         // Verification fail, redirect back
         return Redirect::back()->withInput()->withErrors($validator);
     }
 }