<?php

use Illuminate\Support\Facades\Route;

Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account.'], function () {

    Route::post('/registration', 'CreateCustomerController@create')->name('registration.register');
    Route::post('/invite/registration', 'CreateInvitedCustomerController@create')->name('registration.invite.register');



    Route::group(['prefix' => 'authentication', 'as' => 'authentication.'], function () {
        Route::group(['prefix' => 'login', 'as' => 'authenticate.'], function () {
            Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt');

            Route::post('/cross-attempt', 'UserCrossAuthenticationController@authenticate')->name('cross.attempt');

            Route::post('/check_email', 'CheckEmailController@check')->name('email.check');
        });

        Route::group(['middleware' => 'valid.token'], function () {
            Route::get('/logout', 'UserAuthenticationLogoutController@logout')->name('logout');
            Route::get('/refresh', 'RefreshAuthenticationTokenController@refresh')->name('refresh');
        });

        Route::group(['prefix' => 'password', 'as' => 'password.'], function () {
            Route::post('/forget', 'GeneratePasswordResetController@generate')->name('forget');
            Route::post('/reset', 'ResetPasswordController@reset')->name('reset');
        });
    });

    Route::group(['prefix' => 'email', 'as' => 'email.'], function () {
        Route::post('/verify', 'UserEmailVerificationController@verify')->name('verify');
        Route::post('/verification/resend', 'ResendEmailVerificationController@resend')->name('verification.resend');
    });

    Route::group(['middleware' => 'valid.token', 'prefix' => 'user', 'as' => 'user.'], function () {
        Route::post('/show', 'FetchUserController@fetch')->name('show');
        Route::get('/list', 'ListUsersController@list')->name('list');
        Route::put('/update/{id}', 'UpdateUserController@update')->name('update');
        Route::post('/admin/create', 'CreateAdminUserController@create')->name('admin.create');
        Route::delete('/delete/{id}', 'DeleteUserController@delete')->name('delete');
    });

});
