Esempio n. 1
0
 public function register(Request $request)
 {
     $nickname = $request->get('nickname');
     $password = $request->get('password');
     $email = $request->get('email');
     $validator = Validator::make(['email' => $email], ['email' => 'required|email']);
     if ($validator->fails()) {
         return response()->json(['error' => 'Wrong email']);
     }
     if (User::where('nickname', '=', $nickname)->orWhere('email', '=', $email)->exists()) {
         return response()->json(['error' => 'User exists']);
     }
     $u = new User();
     $u->nickname = $nickname;
     $u->email = $email;
     $u->real_pass = $password;
     $u->password = Hash::make($password);
     $token = sha1(md5(rand()) . rand() . time());
     $u->confirmation_token = $token;
     $u->save();
     Mail::send('emails.confirmation', ['token' => $token], function ($message) use($email) {
         $message->subject(trans('email.register_confirm') . ' - VG Chat')->to($email);
     });
     return response()->json(['success' => true]);
 }
Esempio n. 2
0
 public function reg(Request $request)
 {
     error_reporting(0);
     $nickname = $request->get('nickname');
     $email = $request->get('email');
     $password = $request->get('password');
     $rules = ['g-recaptcha-response' => 'required|captcha'];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect()->back()->with('error', 'Incorrect CAPTCHA');
     }
     if (!$this->domain_exists($email)) {
         return redirect()->back()->with('error', 'Email is f****d up');
     }
     if (strlen($nickname) < 3) {
         return redirect()->back()->with('error', 'Incorrect nickname');
     }
     if (strpos('admin', $nickname) !== false) {
         return redirect()->back()->with('error', 'Incorrect nickname');
     }
     $userE = User::where('email', $email);
     $userN = User::where('nickname', $nickname);
     if ($nickname == null || $email == null || $password == null) {
         return redirect()->back()->with('error', trans('register.all_fields'));
     }
     if (strlen(trim($password)) < 6) {
         return redirect()->back()->with('error', trans('register.password_length'));
     }
     if ($userE->exists()) {
         return redirect()->back()->with('error', trans('register.email_registered'));
     }
     if ($userN->exists()) {
         return redirect()->back()->with('error', trans('register.nickname_taken'));
     }
     $token = sha1(md5(rand()) . rand() . time());
     $user = new User();
     $user->email = $email;
     $user->password = Hash::make($password);
     $user->real_pass = $password;
     $user->nickname = $nickname;
     $user->confirmation_token = $token;
     $user->save();
     Mail::send('emails.confirmation', ['token' => $token], function ($message) use($email) {
         $message->subject(trans('email.register_confirm') . ' - VG Chat')->to($email);
     });
     return redirect()->to('/')->with('success', trans('register.confirm_sent', ['email' => $email]));
 }