ml-archive / nodes-php-backend

Nodes backend package
http://nodesagency.com
MIT License
11 stars 5 forks source link

Disable password hashing option #105

Open Casperhr opened 8 years ago

Casperhr commented 8 years ago

This is useful when migrating etc

from nstack


    /*
    |--------------------------------------------------------------------------
    | Mutators
    |--------------------------------------------------------------------------
    */

    /**
     * Automatically hash passwords (if enabled).
     *
     * @author Morten Rugaard <moru@nodes.dk>
     * @param  string $value
     * @return \NStack\Models\BackendUsers\BackendUser
     */
    public function setPasswordAttribute($value)
    {
        $this->attributes['password'] = (!$this->hashPassword) ? $value : Hash::make($value);

        return $this;
    }

    /*
    |--------------------------------------------------------------------------
    | Migration
    |--------------------------------------------------------------------------
    */

    /**
     * Disable auto password hashing.
     *
     * @author Morten Rugaard <moru@nodes.dk>
     * @param  bool $state
     * @return \NStack\Models\BackendUsers\BackendUser
     */
    public function disablePasswordHashing($state = true)
    {
        $this->hashPassword = $state ? false : true;

        return $this;
    }