async update({ request, response }) {
    try {
      const { token, password } = request.all();

      const user = await User.findByOrFail("token", token);

      const tokenExpired = moment()
        .subtract("2", "days")
        .isAfter(user.token_created_at);

      if (tokenExpired) {
        return response
          .status(401)
          .send({ error: { message: "Token Expired" } });
      }

      user.token = null;
      user.token_created_at = null;
      user.password = password;

      await user.save();
    } catch (err) {
      return response
        .status(err.status)
        .send({ error: { message: "Error in reset password" } });
    }
  }
/**
   * Update password details.
   * PUT properties
   */
Update password details.
PUT properties
Update password details . PUT properties
async update({ request, response }) {
    try {
      const { token, password } = request.all();
      const user = await User.findByOrFail("token", token);
      const tokenExpired = moment()
        .subtract("2", "days")
        .isAfter(user.token_created_at);
      if (tokenExpired) {
        return response
          .status(401)
          .send({ error: { message: "Token Expired" } });
      }
      user.token = null;
      user.token_created_at = null;
      user.password = password;
      await user.save();
    } catch (err) {
      return response
        .status(err.status)
        .send({ error: { message: "Error in reset password" } });
    }
  }
async update ( { request , response } ) { try { const { token , password } = request . all ( ) ; const user = await User . findByOrFail ( "token" , token ) ; const tokenExpired = moment ( ) . subtract ( "2" , "days" ) . isAfter ( user . token_created_at ) ; if ( tokenExpired ) { return response . status ( 401 ) . send ( { error : { message : "Token Expired" } } ) ; } user . token = null ; user . token_created_at = null ; user . password = password ; await user . save ( ) ; } catch ( err ) { return response . status ( err . status ) . send ( { error : { message : "Error in reset password" } } ) ; } }
Update password details.
Update password details .