Skip to content

Full Stack Programmer

Need a website, web app or API?

Full Stack Programmer

Need a website, web app or API?

  • Blog
  • Who am i?
  • More About Me
    • Skills
    • Experience
    • Recommendations
    • Education
    • My Activities
  • IT Services
  • #Instagram
  • Contact
  • Privacy & Policy
Lumen

Lumen/Lumen: Create & Check Password

 Danyal  April 15, 2020  Posted in Laravel Tagged Authentication, hash, login, password

Laravel/Lumen comes with Hash facade that provides the secure Bcrypt & Argon2 hashing for storing user string passwords.

Default Laravel Login & Register Controllers uses Bcrypt for authentication.

Let’s take a look at the basic implementation:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;

class UserController extends Controller
{
    /**
     * Update the password for the user.
     *
     * @param  Request  $request
     * @return Response
     */
    public function update(Request $request)
    {
        $request->user()->fill([
            'password' => Hash::make($request->newPassword)
        ])->save();
    }

    /**
     * Check stored password
     *
     * @param  Request  $request
     * @return Response
     */
    public function check(Request $request)
    {
      $user = User::where('email', '=', 'hello@email.com')->first();
      if ($user) {
          if (Hash::check($request->get('password'), $user->password) {
            // unauthenticated
            return ['error' => 'unauthenticated'];
          }
      }
      return [];
    }
}

Post Views: 2,087
Author: Danyal
I'm working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.

Post navigation

Tip: How to install pip on mac OS →
← Laravel: Usage of old() in form when editing
April 2020
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Feb   May »

Tags

Authentication brew coding commands composer cookies database devops DigitalOcean drupal Eloquent error FREE SSL Git javascript laravel laravel 5.5 Laravel 5.6 laravel5.7 linux lumen LumenPassport migration mysql network osMac permissions php production python quicktip ssh SSL Symfony Symfony 4 technology tip tip of the day tips ubuntu Ubuntu 16.04 Ubuntu 17 Update upgrade vuejs
IT Services
Senior Backend & Frontend Developer
mig@danyal.dk
www.danyal.dk
2500 Valby, Denmark
Backend Skills
Website & Web App Development
PHP Slim, Symfony 3.4, Laravel 5.8 & Lumen 5.8
MVC Applications and RestAPI's Development (PHP 5.6 & PHP 7)
MySQL, MongoDB, PostgresQL
Apache2, Nginx, Caching & Cloud Server Management
Frontend Skills
Javascript, jQuery, AngularJS, CSS3, HTML5, Bootstrap4
Bootstrap4 templating custom SCSS
Nuxtjs & Vuejs
Using in Bold.dk new version and other freelance projects.
Systems & Tools
E-Mail & SMS Marketing & Customer Satisfaction Surveys
SurveyGizmo, eMailPlatform

Recent Posts

  • Build issue with Xcode 12.3 – file not found #include “ruby/config.h”
  • Do you know fact about NSObject?
  • Vuejs: how to access getter from other getter
  • PHP vs Python #2: Variables
  • Drupal: Working with filters criteria

Most Viewed Posts

  • Laravel 5.7 Route [login] not defined (11,455)
  • Install Laravel required PHP & Extentions (8,851)
  • Laravel composer install – Your requirements could not be resolved to an installable set of packages. (8,284)
  • Dual boot windows 10 & Ubuntu 16.04 – Lenovo Y520 (7,122)
  • Vue Loading overlay component (6,912)

RSS Rida.dk

  • English Jokes#1
  • Roman Urdu Jokes #3
  • Roman Urdu Joke#2
  • Roman Urdu Jokes
  • Tips for Today#2
  • Ă…rstider
  • Tip of Today#1
  • Kashmiri Chai

RSS Abdulraheem.dk

  • Facts About Turkey
  • Game Among Us
  • Quiz About Islamabad
  • Facts about Islamabad
  • Facts About Marala Headworks Sialkot
  • Theropoder
  • Facts About Jinnah Stadium
  • Facts About The Sialkot Clock Tower

RSS Abdulsamad.dk

  • Megabots Nr.5
  • Megabots Nr.2
  • Days of the week
  • Playing Archero
  • Table of 11
  • Table of 10
  • Table of 9
  • Table of 8

RSS Laravel News

  • Laravel Themer package: add multi-theme support for Laravel application
  • Generate GitHub Actions Config for Laravel Projects with Ghygen
  • Livewire Make Command can now Scaffold a Component Test
  • Laravel 8.29 Released
  • Create an Animated Scrolling Card with Tailwind

RSS Python Insider

  • Python 3.9.2 and 3.8.8 are now available
  • Python 3.9.2rc1 and 3.8.8rc1 are now available for testing
  • Python 3.7.10 and 3.6.13 security updates now available
  • Python 3.10.0a5 is now available for testing
  • Python 3.10.0a4 is now available for testing

Copyright © 2021 Full Stack Programmer