YetiForceCompany/YetiForceCRM

View on GitHub
api/webservice/WebserviceStandard/Users/ChangePassword.php

Summary

Maintainability
A
0 mins
Test Coverage
C
75%

Avoid using static access to class '\App\Encryption' in method 'put'.
Open

                'password' => \App\Encryption::createPasswordHash($this->controller->request->getRaw('newPassword'), $this->controller->app['type']),

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Encryption' in method 'put'.
Open

        if (\App\Encryption::verifyPasswordHash($this->controller->request->getRaw('currentPassword'), $this->getUserData('password'), $this->controller->app['type'])) {

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Possibly zero references to use statement for classlike/namespace OA (\OpenApi\Annotations)
Open

use OpenApi\Annotations as OA;

Call to method createPasswordHash from undeclared class \App\Encryption (Did you mean class \Tests\App\Encryption)
Open

                'password' => \App\Encryption::createPasswordHash($this->controller->request->getRaw('newPassword'), $this->controller->app['type']),

Call to method verifyPasswordHash from undeclared class \App\Encryption (Did you mean class \Tests\App\Encryption)
Open

        if (\App\Encryption::verifyPasswordHash($this->controller->request->getRaw('currentPassword'), $this->getUserData('password'), $this->controller->app['type'])) {

Spaces must be used for alignment; tabs are not allowed
Open

     *          required=true,

Spaces must be used for alignment; tabs are not allowed
Open

     *             ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

Spaces must be used for alignment; tabs are not allowed
Open

     *    @OA\Schema(

Spaces must be used for alignment; tabs are not allowed
Open

     *        type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *        type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *                 mediaType="multipart/form-data",

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *            title="New password",

Spaces must be used for alignment; tabs are not allowed
Open

     *         title="Users module - Users password change response body",

Spaces must be used for alignment; tabs are not allowed
Open

     *        summary="User password change",

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\JsonContent(ref="#/components/schemas/Users_Put_ChangePassword_Request"),

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\JsonContent(ref="#/components/schemas/Users_Put_ChangePassword_Request"),

Spaces must be used for alignment; tabs are not allowed
Open

     *                 @OA\Schema(ref="#/components/schemas/Users_Put_ChangePassword_Request")

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *    @OA\Schema(

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\XmlContent(ref="#/components/schemas/Users_Put_ChangePassword_Response"),

Spaces must be used for alignment; tabs are not allowed
Open

     *           property="currentPassword",

Spaces must be used for alignment; tabs are not allowed
Open

     *            type="string"

Spaces must be used for alignment; tabs are not allowed
Open

     *         schema="Users_Put_ChangePassword_Response",

Spaces must be used for alignment; tabs are not allowed
Open

     *        required={"status", "result"},

Spaces must be used for alignment; tabs are not allowed
Open

     *        summary="User password change",

Spaces must be used for alignment; tabs are not allowed
Open

     *                 @OA\Schema(ref="#/components/schemas/Users_Put_ChangePassword_Request")

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\XmlContent(ref="#/components/schemas/Users_Put_ChangePassword_Response"),

Spaces must be used for alignment; tabs are not allowed
Open

     *        required={"currentPassword", "newPassword"},

Spaces must be used for alignment; tabs are not allowed
Open

     *            type="string",

Spaces must be used for alignment; tabs are not allowed
Open

     *          description="Input data",

Spaces must be used for alignment; tabs are not allowed
Open

     *             @OA\MediaType(

Spaces must be used for alignment; tabs are not allowed
Open

     *             ),

Spaces must be used for alignment; tabs are not allowed
Open

     *         schema="Users_Put_ChangePassword_Request",

Spaces must be used for alignment; tabs are not allowed
Open

     *        tags={"Users"},

Spaces must be used for alignment; tabs are not allowed
Open

     *      @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *        type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *        description="User password change",

Spaces must be used for alignment; tabs are not allowed
Open

     *             @OA\MediaType(

Spaces must be used for alignment; tabs are not allowed
Open

     *        required={"currentPassword", "newPassword"},

Spaces must be used for alignment; tabs are not allowed
Open

     *                 @OA\Schema(ref="#/components/schemas/Users_Put_ChangePassword_Request")

Spaces must be used for alignment; tabs are not allowed
Open

     *            response=200,

Spaces must be used for alignment; tabs are not allowed
Open

     *            description="Response",

Spaces must be used for alignment; tabs are not allowed
Open

     *            property="newPassword",

Spaces must be used for alignment; tabs are not allowed
Open

     *            type="string"

Spaces must be used for alignment; tabs are not allowed
Open

     *    ),

Spaces must be used for alignment; tabs are not allowed
Open

     *                 @OA\Schema(ref="#/components/schemas/Users_Put_ChangePassword_Request")

Spaces must be used for alignment; tabs are not allowed
Open

     *             ),

Spaces must be used for alignment; tabs are not allowed
Open

     *           property="currentPassword",

Spaces must be used for alignment; tabs are not allowed
Open

     *         ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *        path="/webservice/WebserviceStandard/Users/ChangePassword",

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\RequestBody(

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\RequestBody(

Spaces must be used for alignment; tabs are not allowed
Open

     *                 mediaType="application/x-www-form-urlencoded",

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\JsonContent(ref="#/components/schemas/Users_Put_ChangePassword_Response"),

Spaces must be used for alignment; tabs are not allowed
Open

     *      @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *         ),

Spaces must be used for alignment; tabs are not allowed
Open

     *            property="newPassword",

Spaces must be used for alignment; tabs are not allowed
Open

     * @OA\Schema(

Spaces must be used for alignment; tabs are not allowed
Open

     *             @OA\MediaType(

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

Spaces must be used for alignment; tabs are not allowed
Open

     *            response=200,

Spaces must be used for alignment; tabs are not allowed
Open

     *         schema="Users_Put_ChangePassword_Request",

Spaces must be used for alignment; tabs are not allowed
Open

     *            title="Current password",

Spaces must be used for alignment; tabs are not allowed
Open

     *         schema="Users_Put_ChangePassword_Response",

Spaces must be used for alignment; tabs are not allowed
Open

     *        tags={"Users"},

Spaces must be used for alignment; tabs are not allowed
Open

     *        security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},

Spaces must be used for alignment; tabs are not allowed
Open

     *        security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},

Spaces must be used for alignment; tabs are not allowed
Open

     *          required=true,

Spaces must be used for alignment; tabs are not allowed
Open

     *             ),

Spaces must be used for alignment; tabs are not allowed
Open

     *            description="Response",

Spaces must be used for alignment; tabs are not allowed
Open

     *         title="Users module - Users password change request body",

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *    ),

Spaces must be used for alignment; tabs are not allowed
Open

     *         title="Users module - Users password change response body",

Spaces must be used for alignment; tabs are not allowed
Open

     *                 mediaType="application/x-www-form-urlencoded",

Spaces must be used for alignment; tabs are not allowed
Open

     *         title="Users module - Users password change request body",

Spaces must be used for alignment; tabs are not allowed
Open

     *            title="Current password",

Spaces must be used for alignment; tabs are not allowed
Open

     *            type="string",

Spaces must be used for alignment; tabs are not allowed
Open

     *        required={"status", "result"},

Spaces must be used for alignment; tabs are not allowed
Open

            ]);

Spaces must be used for alignment; tabs are not allowed
Open

    public function put(): bool

Spaces must be used for alignment; tabs are not allowed
Open

     *        description="User password change",

Spaces must be used for alignment; tabs are not allowed
Open

     *          description="Input data",

Spaces must be used for alignment; tabs are not allowed
Open

     *             @OA\MediaType(

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *        type="object",

Spaces must be used for alignment; tabs are not allowed
Open

     *            title="New password",

Spaces must be used for alignment; tabs are not allowed
Open

            ]);

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(property="result", type="boolean", description="Password change status", example=false),

Spaces must be used for alignment; tabs are not allowed
Open

            'status' => 'LBL_FAILED_PASSWORD_CHANGED',

Spaces must be used for alignment; tabs are not allowed
Open

        return false;

Spaces must be used for alignment; tabs are not allowed
Open

    }

Spaces must be used for alignment; tabs are not allowed
Open

    {

Spaces must be used for alignment; tabs are not allowed
Open

                'password' => \App\Encryption::createPasswordHash($this->controller->request->getRaw('newPassword'), $this->controller->app['type']),

Spaces must be used for alignment; tabs are not allowed
Open

            return true;

Spaces must be used for alignment; tabs are not allowed
Open

     *                 mediaType="multipart/form-data",

Spaces must be used for alignment; tabs are not allowed
Open

     *            @OA\JsonContent(ref="#/components/schemas/Users_Put_ChangePassword_Response"),

Spaces must be used for alignment; tabs are not allowed
Open

     * ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     * ),

Spaces must be used for alignment; tabs are not allowed
Open

        if (\App\Encryption::verifyPasswordHash($this->controller->request->getRaw('currentPassword'), $this->getUserData('password'), $this->controller->app['type'])) {

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(property="result", type="boolean", description="Password change status", example=false),

Spaces must be used for alignment; tabs are not allowed
Open

            $this->updateUser([

Spaces must be used for alignment; tabs are not allowed
Open

                'status' => 'LBL_PASSWORD_CHANGED',

Spaces must be used for alignment; tabs are not allowed
Open

            $this->saveLoginHistory([

Spaces must be used for alignment; tabs are not allowed
Open

        $this->saveLoginHistory([

Spaces must be used for alignment; tabs are not allowed
Open

     */

Spaces must be used for alignment; tabs are not allowed
Open

        ]);

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

Spaces must be used for alignment; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

     * @OA\Put(

Spaces must be used to indent lines; tabs are not allowed
Open

     * Put method.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *        path="/webservice/WebserviceStandard/Users/ChangePassword",

Line exceeds 120 characters; contains 131 characters
Open

     *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    public $allowedMethod = ['PUT'];

Spaces must be used to indent lines; tabs are not allowed
Open

    protected function checkPermissionToModule(): void

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc}  */

Spaces must be used to indent lines; tabs are not allowed
Open

    use \Api\Core\Traits\LoginHistory;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @api

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Line exceeds 120 characters; contains 189 characters
Open

     *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc}  */

Line exceeds 120 characters; contains 149 characters
Open

                'password' => \App\Encryption::createPasswordHash($this->controller->request->getRaw('newPassword'), $this->controller->app['type']),

Line exceeds 120 characters; contains 169 characters
Open

        if (\App\Encryption::verifyPasswordHash($this->controller->request->getRaw('currentPassword'), $this->getUserData('password'), $this->controller->app['type'])) {

There are no issues that match your filters.

Category
Status