Completed
Push — develop ( d878ad...d28e4b )
by Abdelrahman
05:14
created

web.php ➔ authentication_routes()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 80
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 42
nc 1
nop 0
dl 0
loc 80
rs 8.8387
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 11 and the first side effect is on line 93.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
declare(strict_types=1);
4
5
if (! function_exists('authentication_routes')) {
6
    /**
7
     * Register authenication routes.
8
     *
9
     * @return void
10
     */
11
    function authentication_routes()
0 ignored issues
show
Coding Style introduced by
As per coding-style, this function should be in camelCase.

CamelCase (...) is the practice of writing compound words or phrases such that
each word or abbreviation begins with a capital letter.

Learn more about camelCase.

Loading history...
12
    {
13
        // Login Routes
14
        Route::get('login')->name('login')->uses('AuthenticationController@form');
15
        Route::post('login')->name('login.process')->uses('AuthenticationController@login');
16
        Route::post('logout')->name('logout')->uses('AuthenticationController@logout');
17
18
        // Registration Routes
19
        Route::get('register')->name('register')->uses('RegistrationController@form');
20
        Route::post('register')->name('register.process')->uses('RegistrationController@register');
21
22
        // Password Reset Routes
23
        Route::name('passwordreset.')->prefix('passwordreset')->group(function () {
24
            Route::get('request')->name('request')->uses('PasswordResetController@request');
25
            Route::post('send')->name('send')->uses('PasswordResetController@send');
26
            Route::get('reset')->name('reset')->uses('PasswordResetController@reset');
27
            Route::post('process')->name('process')->uses('PasswordResetController@process');
28
        });
29
30
        // Verification Routes
31
        Route::name('verification.')->prefix('verification')->group(function () {
32
            // Phone Verification Routes
33
            Route::name('phone.')->prefix('phone')->group(function () {
34
                Route::get('request')->name('request')->uses('PhoneVerificationController@request');
35
                Route::post('send')->name('send')->uses('PhoneVerificationController@send');
36
                Route::get('verify')->name('verify')->uses('PhoneVerificationController@verify');
37
                Route::post('process')->name('process')->uses('PhoneVerificationController@process');
38
            });
39
40
            // Email Verification Routes
41
            Route::name('email.')->prefix('email')->group(function () {
42
                Route::get('request')->name('request')->uses('EmailVerificationController@request');
43
                Route::post('send')->name('send')->uses('EmailVerificationController@send');
44
                Route::get('verify')->name('verify')->uses('EmailVerificationController@verify');
45
            });
46
        });
47
48
        // Account Settings Route Placeholder
49
        Route::redirect('account', '/account/settings')->name('account')->uses('AccountSettingsController@index');
50
51
        // User Account Routes
52
        Route::name('account.')->prefix('account')->group(function () {
53
            // Account Settings Routes
54
            Route::get('settings')->name('settings')->uses('AccountSettingsController@edit');
55
            Route::post('settings')->name('settings.update')->uses('AccountSettingsController@update');
56
57
            // Account Password Routes
58
            Route::get('password')->name('password')->uses('AccountPasswordController@edit');
59
            Route::post('password')->name('password.update')->uses('AccountPasswordController@update');
60
61
            // Account Attributes Routes
62
            Route::get('attributes')->name('attributes')->uses('AccountAttributesController@edit');
63
            Route::post('attributes')->name('attributes.update')->uses('AccountAttributesController@update');
64
65
            // Account Sessions Routes
66
            Route::get('sessions')->name('sessions')->uses('AccountSessionsController@index');
67
            Route::delete('sessions')->name('sessions.flush')->uses('AccountSessionsController@flush');
68
            Route::delete('sessions/{session?}')->name('sessions.delete')->uses('AccountSessionsController@delete');
69
70
            // Account TwoFactor Routes
71
            Route::name('twofactor.')->prefix('twofactor')->group(function () {
72
73
                Route::get('/')->name('index')->uses('TwoFactorSettingsController@index');
74
75
                // Account TwoFactor TOTP Routes
76
                Route::name('totp.')->prefix('totp')->group(function () {
77
                    Route::get('enable')->name('enable')->uses('TwoFactorSettingsController@enableTotp');
78
                    Route::post('update')->name('update')->uses('TwoFactorSettingsController@updateTotp');
79
                    Route::post('disable')->name('disable')->uses('TwoFactorSettingsController@disableTotp');
80
                    Route::post('backup')->name('backup')->uses('TwoFactorSettingsController@backupTotp');
81
                });
82
83
                // Account TwoFactor Phone Routes
84
                Route::name('phone.')->prefix('phone')->group(function () {
85
                    Route::post('enable')->name('enable')->uses('TwoFactorSettingsController@enablePhone');
86
                    Route::post('disable')->name('disable')->uses('TwoFactorSettingsController@disablePhone');
87
                });
88
            });
89
        });
90
    }
91
}
92
93
Route::domain(domain())->group(function () {
94
    Route::name('frontarea.')
95
        ->middleware(['web', 'nohttpcache'])
96
        ->namespace('Cortex\Fort\Http\Controllers\Frontarea')
97
        ->prefix(config('cortex.foundation.route.locale_prefix') ? '{locale}/'.config('cortex.foundation.route.prefix.frontarea') : config('cortex.foundation.route.prefix.frontarea'))->group(function () {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 204 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
98
99
            // Register authenication routes
100
            authentication_routes();
101
102
        });
103
104
105
    Route::name('adminarea.')
106
         ->namespace('Cortex\Fort\Http\Controllers\Adminarea')
107
         ->middleware(['web', 'nohttpcache', 'can:access-adminarea'])
108
         ->prefix(config('cortex.foundation.route.locale_prefix') ? '{locale}/'.config('cortex.foundation.route.prefix.adminarea') : config('cortex.foundation.route.prefix.adminarea'))->group(function () {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 205 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
109
110
         // Abilities Routes
111
         Route::name('abilities.')->prefix('abilities')->group(function () {
112
             Route::get('/')->name('index')->uses('AbilitiesController@index');
113
             Route::get('create')->name('create')->uses('AbilitiesController@form');
114
             Route::post('create')->name('store')->uses('AbilitiesController@store');
115
             Route::get('{ability}')->name('edit')->uses('AbilitiesController@form');
116
             Route::put('{ability}')->name('update')->uses('AbilitiesController@update');
117
             Route::get('{ability}/logs')->name('logs')->uses('AbilitiesController@logs');
118
             Route::delete('{ability}')->name('delete')->uses('AbilitiesController@delete');
119
         });
120
121
         // Roles Routes
122
         Route::name('roles.')->prefix('roles')->group(function () {
123
             Route::get('/')->name('index')->uses('RolesController@index');
124
             Route::get('create')->name('create')->uses('RolesController@form');
125
             Route::post('create')->name('store')->uses('RolesController@store');
126
             Route::get('{role}')->name('edit')->uses('RolesController@form');
127
             Route::put('{role}')->name('update')->uses('RolesController@update');
128
             Route::get('{role}/logs')->name('logs')->uses('RolesController@logs');
129
             Route::delete('{role}')->name('delete')->uses('RolesController@delete');
130
         });
131
132
         // Users Routes
133
         Route::name('users.')->prefix('users')->group(function () {
134
             Route::get('/')->name('index')->uses('UsersController@index');
135
             Route::get('create')->name('create')->uses('UsersController@form');
136
             Route::post('create')->name('store')->uses('UsersController@store');
137
             Route::get('{user}')->name('edit')->uses('UsersController@form');
138
             Route::put('{user}')->name('update')->uses('UsersController@update');
139
             Route::get('{user}/logs')->name('logs')->uses('UsersController@logs');
140
             Route::get('{user}/activities')->name('activities')->uses('UsersController@activities');
141
             Route::delete('{user}')->name('delete')->uses('UsersController@delete');
142
             Route::delete('{user}/media/{media}')->name('media.delete')->uses('UsersController@deleteMedia');
143
         });
144
     });
145
});
146
147
148
Route::domain('{subdomain}.'.domain())->group(function () {
149
150
    Route::name('managerarea.')
151
         ->namespace('Cortex\Fort\Http\Controllers\Managerarea')
152
         ->middleware(['web', 'nohttpcache', 'can:access-managerarea'])
153
         ->prefix(config('cortex.foundation.route.locale_prefix') ? '{locale}/'.config('cortex.tenants.route.prefix.managerarea') : config('cortex.tenants.route.prefix.managerarea'))->group(function () {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 203 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
154
155
         // Roles Routes
156
         Route::name('roles.')->prefix('roles')->group(function () {
157
             Route::get('/')->name('index')->uses('RolesController@index');
158
             Route::get('create')->name('create')->uses('RolesController@form');
159
             Route::post('create')->name('store')->uses('RolesController@store');
160
             Route::get('{role}')->name('edit')->uses('RolesController@form');
161
             Route::put('{role}')->name('update')->uses('RolesController@update');
162
             Route::get('{role}/logs')->name('logs')->uses('RolesController@logs');
163
             Route::delete('{role}')->name('delete')->uses('RolesController@delete');
164
         });
165
166
         // Users Routes
167
         Route::name('users.')->prefix('users')->group(function () {
168
             Route::get('/')->name('index')->uses('UsersController@index');
169
             Route::get('create')->name('create')->uses('UsersController@form');
170
             Route::post('create')->name('store')->uses('UsersController@store');
171
             Route::get('{user}')->name('edit')->uses('UsersController@form');
172
             Route::put('{user}')->name('update')->uses('UsersController@update');
173
             Route::get('{user}/logs')->name('logs')->uses('UsersController@logs');
174
             Route::get('{user}/activities')->name('activities')->uses('UsersController@activities');
175
             Route::delete('{user}')->name('delete')->uses('UsersController@delete');
176
             Route::delete('{user}/media/{media}')->name('media.delete')->uses('UsersController@deleteMedia');
177
         });
178
     });
179
180
181
    Route::name('tenantarea.')
182
        ->middleware(['web', 'nohttpcache'])
183
        ->namespace('Cortex\Fort\Http\Controllers\Tenantarea')
184
        ->prefix(config('cortex.foundation.route.locale_prefix') ? '{locale}/'.config('cortex.foundation.route.prefix.tenantarea') : config('cortex.foundation.route.prefix.tenantarea'))->group(function () {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 206 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
185
186
        // Register authenication routes
187
        authentication_routes();
188
189
        // Social Authentication Routes
190
        Route::redirect('auth', 'login');
191
        Route::get('auth/{provider}')->name('auth.social')->uses('SocialAuthenticationController@redirectToProvider');
192
        Route::get('auth/{provider}/callback')->name('auth.social.callback')->uses('SocialAuthenticationController@handleProviderCallback');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 140 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
193
194
    });
195
196
});
197