public function enableTwoFactorAuth(Request $request)
    {
        if (! is_null($response = $this->validateEnablingTwoFactorAuth($request))) {
            return $response;
        }

        $user = Auth::user();

        $user->setAuthPhoneInformation(
            $request->country_code, $request->phone_number
        );

        try {
            Spark::twoFactorProvider()->register($user);
        } catch (Exception $e) {
            app(ExceptionHandler::class)->report($e);

            return response()->json(['The provided phone information is invalid.'], 422);
        }

        $user->save();

        return $this->users->getCurrentUser();
    }
public function enableTwoFactorAuth(Request $request)
    {
        if (! is_null($response = $this->validateEnablingTwoFactorAuth($request))) {
            return $response;
        }

        $user = Auth::user();

        $user->setAuthPhoneInformation(
            $request->country_code, $request->phone_number
        );

        try {
            Spark::twoFactorProvider()->register($user);
        } catch (Exception $e) {
            app(ExceptionHandler::class)->report($e);

            return response()->json(['The provided phone information is invalid.'], 422);
        }

        $user->save();

        return $this->users->getCurrentUser();
    }
public function enableTwoFactorAuth ( Request $ request ) { if ( ! is_null ( $ response = $ this -> validateEnablingTwoFactorAuth ( $ request ) ) ) { return $ response ; } $ user = Auth :: user ( ) ; $ user -> setAuthPhoneInformation ( $ request -> country_code , $ request -> phone_number ) ; try { Spark :: twoFactorProvider ( ) -> register ( $ user ) ; } catch ( Exception $ e ) { app ( ExceptionHandler :: class ) -> report ( $ e ) ; return response ( ) -> json ( [ 'The provided phone information is invalid.' ] , 422 ) ; } $ user -> save ( ) ; return $ this -> users -> getCurrentUser ( ) ; }
Enable two-factor authentication for the user.

@param  \Illuminate\Http\Request  $request
@return \Illuminate\Http\Response
Enable two - factor authentication for the user .