GithubHelp home page GithubHelp logo

Comments (7)

Mahmoudz avatar Mahmoudz commented on July 19, 2024 1

@llstarscreamll this is related to the Dingo API package, because they override the default Laravel Exception rendering.

I tried adding something like this:

        if (!$request->expectsJson()) {
            return app()->make(\Illuminate\Foundation\Exceptions\Handler::class)->render($request, $exception);
        }

in the render() function but didn't worked, I didn't spend enough time on it.

from apiato.

llstarscreamll avatar llstarscreamll commented on July 19, 2024 1

Hi @Mahmoudz, I have found a solution for this issue by making a small change on the app/Ship/Parents/Requests/RequestTrait.php and setting API_PREFIX=api, I have the PR ready but #115 should be merged first...

from apiato.

llstarscreamll avatar llstarscreamll commented on July 19, 2024

Hi...

I have been writing some tests for fix some bugs and features on the Web Authentication container, would be great to have this fixed to get better error display formatting on web routes. I tried to fix it, but was very confusing to me searching where the exceptions are triggered on web requests. Even try/catch on Task didn't work, the exception is ever triggered.

Thanks!!

from apiato.

llstarscreamll avatar llstarscreamll commented on July 19, 2024

Excuse me, try/catch works, I forgot include the exception class namespace on the controller. It's a ugly way but until the fix arrives, it would be like this:

<?php
namespace App\Containers\Authentication\UI\WEB\Controllers;

// ...
use App\Containers\Authentication\Exceptions\AuthenticationFailedException;

class Controller extends PortWebController
{
    public function loginAdmin(LoginRequest $request, WebAdminLoginAction $action)
    {
        try {
            $result = $action->run($request->email, $request->password, $request->remember_me);
        } catch (AuthenticationFailedException $e) {
            return redirect('/login')->with('status', $e->message);
        }

        if (is_array($result)) {
            return redirect('/login')->with($result);
        }

        return redirect('/dashboard');
    }
}

Off course, Form Requests still fail, no way to prevent it, unless we made validations within controller, but doesn't follow the PORTO conventions and is ugly++, jejeje.

from apiato.

llstarscreamll avatar llstarscreamll commented on July 19, 2024

Hi @Mahmoudz,

I have now correct web errors by setting API_PREFIX=api on the .env file, based on this Laracast question. I have tried 500 error from now, since there is a problem with Session on web routes and can't do much...

from apiato.

Mahmoudz avatar Mahmoudz commented on July 19, 2024

@llstarscreamll thank you man, I've merged your first PR, you're free to send this one anytime.

from apiato.

Mahmoudz avatar Mahmoudz commented on July 19, 2024

closed by #116

from apiato.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.