Laravel

Reset Your Password from API

UPDATE 27/4/2018 – New blog post about reset password from an API – LARAVEL: RESET PASSWORD FROM AN API. Much more simpler than this one.

As you may know, Laravel provide a scaffold auth, which include reset/forgot password on web applications side. But what if you have a mobile application that need to reset password from the mobile application?

In this post, I’ll show you how to reset user’s password from an API in Laravel.

UPDATE 02/07/2017:

In case you’re looking for AppTransformersJson, you basically can create a class called Json in app/Transformers directory.

In the Json class:

<?php

namespace AppTransformers;

class Json
{
    public static function response($data = null, $message = null)
    {
        return [
            'data'    => $data,
            'message' => $message,
        ];
    }
}

Please make sure to composer dumpautoload -o afterward.

UPDATE 27/4/2018 – New blog post about reset password from an API – LARAVEL: RESET PASSWORD FROM AN API. Much more simpler than this one.

27 thoughts on “Reset Your Password from API

  1. This needs further user validation.
    Any user can reset the password of another user just by knowing the email address.

  2. Question, won’t this allow someone to reset anybody’s password? You probably want the token to be sent to the email still, to validate whether the user is allowed to reset this password.

    1. ahh..i’m trying to find back where I put my codes for the Transformers part, but couldn’t find it.

      But what it does it’s basically transform from one data structure to another data structure format so that the response will be standard across the application.

      I’ll update my post shortly how to make one Json Transformer based on this article.

    1. yes, it’s just a POC to make the possibility to reset the password from API – you may need to implement back the way how the web version working OR use 2FA to reset OR use SMS Code to reset the password.

  3. With the release of Laraven and Lumen 5.5 – Is there a probability where you can make another tutorial of this feature using only Lumen 5.5 stateless API instead? Thank you beforehand.

    1. I’ve update in code snippet above.

      Anyway, you want much more simpler solution, I just write new blog post –

  4. $response = $this->broker()->reset(
    $this->credentials($request), function ($user, $password) {
    $this->resetPassword($user, $password);
    }
    );

    NOT working and also i cant understood whats saying this code
    please help us.
    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

nine + 1 =