was the account verified?
my registration Proccess is HACKED! (how?) (L5.1 version)
A Suspicious database record entry blocked (not working) entire registration page (Error on posting). Until now I have at least 500 entries in my users table. Its the first time of my life i see anything like this:
Below you can see the suspicious record in image preview. [img]https://i.imgur.com/cBzvrcd.png[/img]
I dont understand how that happent. Any Ideas???
Below is all Registration proccess:
Register Controller:
public function postRegister(Request $request)
{
$validator = \Validator::make($request->all(), $this->rules(), $this->messages());
if ($validator->fails()){
// flash()->error('Caution! ', 'Wrong data.');
return redirect()
->action('Auth\AuthController@getRegister')
->with('type','register')
->withErrors($validator)
->withInput();
}
$new_user = Register::firstOrCreate(['email' => $request->get('email')]);
$token = Str::random(128);
if($new_user->exists()){
$new_user->update($this->registerFields($request,$token));
}else{
abort(403);
//$new_user->create($this->registerFields($request, $token));
}
\Mail::send('emails.activate_register',[
'token' => $token
], function($m) use ($new_user) {
$m->from('info@myserver', 'Info')
->to($new_user->email)
->subject('One step to complete registration');
});
return view('frontend.auth.success-registration', compact('token'));
}
protected function registerFields(Request $request, $token)
{
return array(
'username' => $request->get('username'),
'email' => $request->get('email'),
'password' => bcrypt($request->get('password')),
'token' => $token
);
}
private function rules()
{
$recaptcha = [
'g-recaptcha-response' => 'required|checkcaptcha'
];
$rules = [
'username' => 'required|min:3|max:15|unique:users,username',
'email' => 'required|email|unique:users,email',
'password' => 'required|confirmed|regex:/^[a-zA-Z0-9].{7,15}$/',
'terms' => 'required'
];
if(\Config::get('recaptcha.enabled')){
return $rules + $recaptcha;
}else{
return $rules;
}
}
Register MODEL:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Register extends Model
{
//
protected $table = 'registration';
protected $fillable = [
'username',
'email',
'password',
'token'
];
}
Register Form (blade file)
<form id="register-form"
action="{!! url('try/register') !!}"
method="post"
role="form"
class="auth-form"
>
@include('errors.list')
{!! csrf_field() !!}
<div class="form-group">
<label>E-mail</label>
<input tabindex="1" type="email" name="email" class="form-control" value="{!! old('email') !!}">
</div>
<div class="form-group">
<label>Username</label>
<input tabindex="2" type="text" name="username" class="form-control" value="{!! old('username') !!}">
</div>
<div class="form-group form-group--relative">
<label>Password <span class="rules">MIN 8 CHARACTERS</span></label>
<input tabindex="3" type="password" name="password" class="form-control" id="login-password">
<button type="button" class="button button--secondary button--password js-password-show" data-target="login-password">
<span class="icon-lamp">
<span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span><span class="path5"></span><span class="path6"></span><span class="path7"></span><span class="path8"></span>
</span>
</button>
</div>
<div class="form-group form-group--relative">
<label>Confirm Password</label>
<input tabindex="4" type="password" name="password_confirmation" class="form-control" id="login-password">
</div>
@if(Config::get('recaptcha.enabled'))
<div class="form-group">
<div class="col-sm-6 col-sm-offset-3">
<div class="g-recaptcha" data-sitekey="{!! config('recaptcha.site_key') !!}"></div>
</div>
</div>
@endif
<p class="terms">
<input type="checkbox" name="terms"/>
I Agree to the <a href="{!! url('terms&conditions') !!}"><strong>Terms and Conditions</strong></a>.
</p>
<p><button type="submit" class="button button--secondary button--bold button--sm button--submit">Register Now</button> </p>
</form>
Syntax of my registration Table (mySQL) [img]https://i.imgur.com/4cQySvV.png[/img]
Looking at your code, I think there was an error in the part
$new_user->update($this->registerFields($request,$token));
Check your log around 27-12 13:31 for an SQL error. If there is, that's where it went wrong.
First it created an empty row with only an email field Then it tried to update that row, but failed for some reason, leaving the row with only an email.
Please or to participate in this conversation.