apa penyebab These credentials do not match our records ??

apa penyebab These credentials do not match our records ketika register masuk, tapi setelah logout dan login ulang tdk bisa. setelah saya pastikan dengan regis ulang dengna menyimpan password tetap sama halisnya

view

 <div class="login-box-body">
     <!-- BEGIN NOTIFICATION -->
                    @if (session('status'))
                    <div class="alert alert-success">
                        {{ session('status') }}
                    </div>
                    @endif
                    @if (session('warning'))
                    <div class="alert alert-warning">
                        {{ session('warning') }}
                    </div>
                    @endif
                    <!-- END NOTIFICATION -->
        <p class="login-box-msg">Sign in to start your session</p>

        <form method="post" action="{{ url('/login') }}">
            {!! csrf_field() !!}

            <div class="form-group has-feedback {{ $errors->has('email') ? ' has-error' : '' }}">
                <input type="text" class="form-control" name="email" value="{{ old('email') }}" placeholder="Email">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
                @if ($errors->has('email'))
                    <span class="help-block">
                    <strong>{{ $errors->first('email') }}</strong>
                </span>
                @endif
            </div>

            <div class="form-group has-feedback{{ $errors->has('password') ? ' has-error' : '' }}">
                <input type="password" class="form-control" placeholder="Password" name="password">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                @if ($errors->has('password'))
                    <span class="help-block">
                    <strong>{{ $errors->first('password') }}</strong>
                </span>
                @endif

            </div>


            <div class="row">
                <div class="col-xs-8">
                    <div class="checkbox icheck">
                        <label>
                            <input type="checkbox" name="remember"> Remember Me
                        </label>
                    </div>
                </div>
                <!-- /.col -->
                <div class="col-xs-4">
                    <button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button>
                </div>
                <!-- /.col -->
            </div>
        </form>

        <a href="{{ url('/password/reset') }}">I forgot my password</a><br>
        <a href="{{ url('/register') }}" class="text-center">Register a new membership</a>

    </div>

LoginController

 <?php

namespace App\Http\Controllers\Auth;
use Illuminate\Support\Facades\Hash;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use App\ActivationService;
use App\ActivationRepository;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct(ActivationService $activationService)
    {
        $this->middleware('guest', ['except' => 'logout']);
        $this->activationService = $activationService;
    }

    public function authenticated(Request $request, $user){
        if (!$user->activated) {
            $this->activationService->sendActivationMail($user);
            auth()->logout();
            return back()->with('warning', 'Anda Harus Komfirmasi Email Terlebeih Dahulu. Kami Telah Mingirim Email Komfirmasi, Silahkan Cek Email Anda.');
        }
        return redirect()->intended($this->redirectPath());
    }

}

Activation service

 <?php
namespace App;

use App\Notifications\ConfirmUserEmail;
use App\ActivationRepository;

class ActivationService{


    protected $activationRepo;
    protected $resendAfter = 24;

    public function __construct(ActivationRepository $activationRepo){
        $this->activationRepo = $activationRepo;
    }

    public function sendActivationMail($user){
        if($user->activated || !$this->shouldSend($user)){
            return;
        }
        $token = $this->activationRepo->createActivation($user);
        $user->notify(new ConfirmUserEmail($token));
    }

    public function activateUser($token){
        $activation = $this->activationRepo->getActivationByToken($token);
        if($activation === null){
            return null;
        }
        $user = User::find($activation->user_id);
        $user->activated = true;
        $user->save();
        $this->activationRepo->deleteActivation($token);
        return $user;
    }

    private function shouldSend($user){
        $activation = $this->activationRepo->getActivation($user);
        return $activation === null || strtotime($activation->created_at) + 60 * 60 * $this->resendAfter < time();
    }

}

AcivationRepositori

 <?php
namespace App;

use Carbon\Carbon;
use Illuminate\Database\Connection;

class ActivationRepository{

    protected $db;
    protected $table = "userAktivasi";

    public function __construct(Connection $db){
        $this->db = $db;
    }

    protected function getToken(){
        return hash_hmac('sha256', str_random(40), config('app.key'));
    }

    public function createActivation($user){
        $activation = $this->getActivation($user);
        if(!$activation){
            return $this->createToken($user);
        }
        return $this->regenerateToken($user);
    }

    private function regenerateToken($user){
        $token = $this->getToken();
        $this->db->table($this->table)->where('user_id', $user->id)->update([
            'token' => $token,
            'created_at' => new Carbon()
        ]);
        return $token;
    }

    private function createToken($user){
        $token = $this->getToken();
        $this->db->table($this->table)->insert([
            'user_id' => $user->id,
            'token' => $token,
            'created_at' => new Carbon()
        ]);
        return $token;
    }

    public function getActivation($user){
        return $this->db->table($this->table)->where('user_id', $user->id)->first();
    }

    public function getActivationByToken($token){
        return $this->db->table($this->table)->where('token', $token)->first();
    }

    public function deleteActivation($token){
        return $this->db->table($this->table)->where('token', $token)->delete();
    }
}

db user

 <?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->string('access')->default('user');
            $table->string('username')->nullable()->unique();
            $table->string('type_of_identity')->nullable();
            $table->text('identity_number')->nullable();
            $table->string('gender')->nullable();
            $table->string('phone')->nullable()->unique();
            $table->string('job')->nullable();
            $table->string('address')->nullable();
            $table->string('districts')->nullable();
            $table->string('city')->nullable();
            $table->string('province')->nullable();
            $table->string('zip_kode')->nullable();
            $table->text('picture')->nullable();
            $table->boolean('activated')->default(false);
            $table->rememberToken();
            $table->timestamps();
            $table->date('deleted_at')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

db useraktivasi

 <?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class UserAktivasi extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
         Schema::create('UserAktivasi', function (Blueprint $table) {
            $table->integer('user_id')->unsigned();
            $table->string('token')->index();
             $table->timestamp('created_at');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
         Schema::dropIfExists('UserAktivasi');
    }
}

avatar suryadisaputra
@suryadisaputra

19 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

5 Jawaban:

udah solve blum om?

avatar unhackme
@unhackme

27 Kontribusi 13 Poin

Dipost 6 tahun yang lalu

Belom Om masih gagal om @unhackme. siapa tau ada petunjuk om??

avatar suryadisaputra
@suryadisaputra

19 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

Kalo tidak salah dari code nya itu membuat registrasi user dengan email verification ya? Sudah debug apa saja yang terkirim ke method login nya?

avatar unhackme
@unhackme

27 Kontribusi 13 Poin

Dipost 6 tahun yang lalu

iya gan, ane ga mengerti baru pemula jg script kiddie gitu

 <?php
namespace App\Http\Controllers\Auth;
use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */
    use AuthenticatesUsers;
    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/';
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);
    }
    /**
     * Handle a login request to the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
     */
    public function login(Request $request)
    {
        $this->validateLogin($request);
        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the User making these requests into this application.
        if ($this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);
            return $this->sendLockoutResponse($request);
        }
        // Customization: Validate if User status is active (1)
        if ($this->attemptLogin($request)) {
            return $this->sendLoginResponse($request);
        }
        // Customization: Validate if User status is active (1)
        $email = $request->get($this->username());
        // Customization: It's assumed that email field should be an unique field
        $User = User::where($this->username(), $email)->first();
        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
        $this->incrementLoginAttempts($request);
        // Customization: If User status is inactive (0) return failed_status error.
        if ($User->activated === 0) {
            return $this->sendFailedLoginResponse($request, 'auth.failed_status');
        }
        return $this->sendFailedLoginResponse($request);
    }
    /**
     * Get the needed authorization credentials from the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    protected function credentials(Request $request)
    {
        $credentials = $request->only($this->username(), 'password');
        // Customization: validate if User status is active (1)
        $credentials['activated'] = 1;
        return $credentials;
    }
    /**
     * Get the failed login response instance.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  string  $field
     * @return \Illuminate\Http\RedirectResponse
     */
    protected function sendFailedLoginResponse(Request $request, $trans = 'auth.failed')
    {
        $errors = [$this->username() => trans($trans)];
        if ($request->expectsJson()) {
            return response()->json($errors, 422);
        }
        return redirect()->back()
            ->withInput($request->only($this->username(), 'remember'))
            ->withErrors($errors);
    }
}
avatar suryadisaputra
@suryadisaputra

19 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

beberapa hari yang lalu saya menulis tentang itu coba di baca disini https://medium.com/@dev.gowa/register-dengan-verifikasi-email-menggunakan-laravel-part-1-c468d859856f

avatar unhackme
@unhackme

27 Kontribusi 13 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban