128 lines
No EOL
3.4 KiB
PHP
Executable file
128 lines
No EOL
3.4 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Mail\MailContact;
|
|
use App\Mail\MailVerifyAccount;
|
|
use App\Repositories\UserRepository;
|
|
use App\Services\UserService;
|
|
use App\User;
|
|
use GuzzleHttp\Client;
|
|
use Input;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use App\Services\Util;
|
|
use Validator;
|
|
|
|
|
|
class RegisterController extends Controller
|
|
{
|
|
|
|
private $GOOGLE_ReCAPTCHA_KEY = "6LeeZosUAAAAAG907fMMqO4BFgsiR4ANDodd8FlU";
|
|
private $GOOGLE_ReCAPTCHA_SECRET = "6LeeZosUAAAAADIy2fyR4RG3EuM-Zdz7Pa2Qmb1J";
|
|
|
|
protected $userRepo;
|
|
|
|
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
|
|
public function __construct(UserRepository $userRepo)
|
|
{
|
|
$this->userRepo = $userRepo;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
|
|
|
|
$data = [
|
|
'GOOGLE_ReCAPTCHA_KEY' => $this->GOOGLE_ReCAPTCHA_KEY,
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
return view('web.templates.registrierung', $data);
|
|
|
|
}
|
|
|
|
public function register(){
|
|
|
|
|
|
$rules = array(
|
|
'first_name'=>'required',
|
|
'last_name'=>'required',
|
|
'salutation' => 'required',
|
|
'email' => 'required|string|email|max:255|unique:users',
|
|
'email-confirm' => 'required|same:email',
|
|
'password' => 'required|string|min:6|confirmed',
|
|
'password_confirmation' => 'required|string|min:6',
|
|
// 'g-recaptcha-response'=>'required|recaptcha',
|
|
'accepted_data_protection' => 'required',
|
|
);
|
|
|
|
/*Validator::extend('recaptcha', function($attribute, $value, $parameters, $validator) {
|
|
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
|
|
});*/
|
|
|
|
$validator = Validator::make(Input::all(), $rules);
|
|
if ($validator->fails()) {
|
|
return back()->withErrors($validator)->withErrors($validator)->withInput(Input::all());
|
|
}
|
|
|
|
$user_shop = Util::getUserShop();
|
|
|
|
$data = Input::all();
|
|
$user = $this->userRepo->create($data);
|
|
|
|
$confirmation_code = UserService::createConfirmationCode();
|
|
|
|
$user->lang = !empty(\App::getLocale()) ? \App::getLocale() : "de";
|
|
$user->confirmation_code = $confirmation_code;
|
|
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
|
|
$user->confirmation_code_remider = 0;
|
|
$user->m_sponsor = $user_shop->user->id;
|
|
$user->m_level = 1;
|
|
$user->save();
|
|
|
|
$user->account->data_protection = now();
|
|
$user->account->save();
|
|
|
|
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
|
|
return redirect('/registrierung/finish');
|
|
|
|
|
|
}
|
|
|
|
public function finish()
|
|
{
|
|
$data = [
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
return view('web.templates.registrierung_finish', $data);
|
|
}
|
|
/*
|
|
private function reCaptcha_validate($attribute, $value, $parameters, $validator)
|
|
{
|
|
|
|
$client = new Client();
|
|
|
|
$response = $client->post(
|
|
'https://www.google.com/recaptcha/api/siteverify',
|
|
['form_params' =>
|
|
[
|
|
'secret' => $this->GOOGLE_ReCAPTCHA_SECRET,
|
|
'response' => $value
|
|
]
|
|
]
|
|
);
|
|
|
|
$body = json_decode((string)$response->getBody());
|
|
return $body->success;
|
|
}
|
|
*/
|
|
|
|
|
|
} |