Welcome Guest, Not a member yet? Register   Sign In
myth-auth How not to load the default routes
#1

Hi everyone, I am using myth for authentication in a study application. In the file "vendor\myth\auth\src\Config\Routes.php" 

PHP Code:
<?php

/*
 * Myth:Auth routes file.
 */
$routes->group('', ['namespace' => 'Myth\Auth\Controllers'], function ($routes) {
    // Login/out
    $routes->get('login''AuthController::login', ['as' => 'login']);
    $routes->post('login''AuthController::attemptLogin');
    $routes->get('logout''AuthController::logout');

    // Registration
    $routes->get('register''AuthController::register', ['as' => 'register']);
    $routes->post('register''AuthController::attemptRegister');

    // Activation
    $routes->get('activate-account''AuthController::activateAccount', ['as' => 'activate-account']);
    $routes->get('resend-activate-account''AuthController::resendActivateAccount', ['as' => 'resend-activate-account']);

    // Forgot/Resets
    $routes->get('forgot''AuthController::forgotPassword', ['as' => 'forgot']);
    $routes->post('forgot''AuthController::attemptForgot');
    $routes->get('reset-password''AuthController::resetPassword', ['as' => 'reset-password']);
    $routes->post('reset-password''AuthController::attemptReset');
}); 


I just wanted to use the login route, however if I make changes to this file in a future change my changes would be overwritten.

Any way to do this?

Thank you all!
Reply
#2

(This post was last modified: 06-09-2021, 04:40 PM by ikesela.)

auth:publish ( -> php spark auth:publish ), edit the publish file, dont edit source, after publish, file will be copied to VIEW/Auth , for the route u need to remove namespace , since all file in main view
Reply
#3

Comment routes you dont need

/* like thst*/
Reply
#4

(This post was last modified: 06-10-2021, 08:01 AM by rafinhaa. Edit Reason: edit )

(06-09-2021, 10:41 PM)paliz Wrote: Comment routes you dont  need

/* like thst*/
That way in a future update the file will be rewritten and my changes erased







(06-09-2021, 04:38 PM)ikesela Wrote: auth:publish ( -> php spark auth:publish ), edit the publish file, dont edit source, after publish, file will be copied to VIEW/Auth , for the route u need to remove namespace , since all file in main view


I only published the auth config edited the $views variable to:



PHP Code:
public $views = [
 
'login' => 'App\Views\layouts\login',
 ]; 

when url access gives an exception:

[Image: Screenshot-1.png]

My route file:

PHP Code:
$routes->group('/', ['filter' => 'login'], function($routes){
 
$routes->get('''CDR\Dashboard::index');
 
$routes->group('users', function($routes){
 
$routes->get('add''CDR\Users::add');
 });
}); 

edit
I don't think I understand very well, do I need to remove the myth-auth namespace?
Reply
#5

yes you need it

$routes->group('', ['namespace' => 'Myth\Auth\Controllers'], function ($routes) {
}
Reply
#6

(06-11-2021, 10:17 AM)paliz Wrote: yes you need it

$routes->group('', ['namespace' => 'Myth\Auth\Controllers'], function ($routes) {
}
If I use namespace my controllers is not found

PHP Code:
$routes->group('/', ['namespace' => 'Myth\Auth\Controllers'], function($routes){
 
$routes->get('''CDR\Dashboard::index');
 
$routes->group('users', function($routes){
 
$routes->get('add''CDR\Users::add');
 
$routes->post('add''CDR\Users::store');
 });
}); 



404 Not Found
Controller or its method was not found: \Myth\Auth\Controllers\CDR\ Dashboard :: index

is there any way to do it?
Reply
#7

Put dashbord ctl in app/conttoller
Reply
#8

(06-11-2021, 07:46 PM)paliz Wrote: Put dashbord ctl in app/conttoller

I tried different ways, followed your tips, but to no avail.

I had to do it this way:
PHP Code:
$routes->group('/', ['filter' => 'login'], function($routes){
 
/** Redirect attempts to Registration, Activation and Forgot/Resets */
 
$routes->match(['get''post'], 'register''CDR\Dashboard::index');
 
$routes->get('activate-account''CDR\Dashboard::index');
 
$routes->get('resend-activate-accoun''CDR\Dashboard::index');
 
$routes->match(['get''post'], 'forgot''CDR\Dashboard::index');
 
$routes->match(['get''post'], 'reset-password''CDR\Dashboard::index');
 
/** Redirect end */
 
$routes->get('''CDR\Dashboard::index');
 
$routes->group('users', function($routes){
 
$routes->get('add''CDR\Users::add');
 
$routes->post('add''CDR\Users::store');
 });
}); 
Reply
#9

after publish, system will copy firl AuthController to controller folder. myth auth config/routes.php , remove the name space for route. it will load from main view folder : View/Auth
Reply
#10

(This post was last modified: Yesterday, 06:50 PM by rafinhaa.)

(Yesterday, 12:17 PM)ikesela Wrote: after publish, system will copy firl AuthController to controller folder. myth auth  config/routes.php , remove the name space for route. it will load from main view folder : View/Auth

That doesn't work either, keep using myth-auth/src/Config/Routes.php
Reply




Theme © iAndrew 2016 - Forum software by © MyBB