crater-invoice-inc/crater · error · ValidationException

Customer portal not available for this user.

Error message

Customer portal not available for this user.

What it means

Customer portal login aborts when the authenticated customer's account does not have portal access enabled for that company — credentials may be correct but the user lacks the portal-enabled flag, so the controller refuses to issue a token/session.

Solutions

  1. Enable the customer portal setting on the customer's company/user record before retrying login
  2. Return a distinct, user-friendly message explaining portal access is disabled rather than a generic error
  3. Check the portal-availability flag before the password check so an authorized-looking user gets an accurate message
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at app/Http/Controllers/V1/Customer/Auth/LoginController.php:34 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of crater-invoice-inc/crater@05d5ce26fd (2026-09-13). Data as JSON: /api/errors/d331fab3f48b753f. Report an issue: GitHub.

Appendix: source

Thrown at app/Http/Controllers/V1/Customer/Auth/LoginController.php:34

     * Handle the incoming request.
     *
     * @param  \Crater\Http\Requests\Customer\CustomerLoginRequest  $request
     * @return \Illuminate\Http\Response
     */
    public function __invoke(CustomerLoginRequest $request, Company $company)
    {
        $user = Customer::where('email', $request->email)
            ->where('company_id', $company->id)
            ->first();

        if (! $user || ! Hash::check($request->password, $user->password)) {
            throw ValidationException::withMessages([
                'email' => ['The provided credentials are incorrect.'],
            ]);
        }

        if (! $user->enable_portal) {
            throw ValidationException::withMessages([
                'email' => ['Customer portal not available for this user.'],
            ]);
        }

        Auth::guard('customer')->login($user);

        return response()->json([
            'success' => true
        ]);
    }
}

View on GitHub (pinned to 05d5ce26fd)