Download the PHP package vantezzen/laravel-account-portal without Composer

On this page you can find all versions of the php package vantezzen/laravel-account-portal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-account-portal

Laravel Account Portal

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

🌌 Quickly switch into user accounts of your Laravel app for debugging, testing etc.

This package allows your admin or support staff to easily log into any user account to view your app with their data.

Under the hood, this package simply logs you into the portal user account, saving the original account info in the session to allow you to switch back.

About

When building systems I noticed that we build the same functionality into almost all of our products:

We create a simple page, a button or API where support staff or developers can enter an email of a user or search though a list of users and log in to our app using that user's account. In some other apps I've also seen similar functionality or even worse just a "master password" that can be input as the password to log into every account without further verification.

This functionality is useful when users complain about something not working or have questions about data they created in their account so that we can view the app exactly the way they would.

In different projects this functionality might have different names - account portal, guest view, user view, support view, direct access, support login etc. - but they mostly work the same.

This package tries to be as unopinionated as possible: It doesn't define a fixed API, pre-build dashboard or makes assumptions about your user models. Instead, this package tries to provide an abstracted API for working with authenticatable classes and user sessions. Everything else - an API, interface or buttons in your frontend - can be added by you based on your apps needs.

Installation

You can install the package via composer:

You can publish the config file with:

Defining Gate

This package requires you to define the Gate "use-account-portal" in order to protect the portal functionality from unauthorized use.

For example, you might add such a Gate definition to your AppServiceProvider:

Your gate should determine, if the user $currentUser is authorized to open a portal into the account of $portalUser though please note that $portalUser might be null if checking that the current user is allowed to use the feature at all.

Usage

This package only provides a class to easily open and close account portals - you probably need to create an API controller or similar to suit the needs of your app.

Get instance

To control the portal, you will need an instance of the "Vantezzen\LaravelAccountPortal\LaravelAccountPortal" class. You can use Laravel's dependency injection or create the class manually:

Session Storage

This package uses the current session to store information about the portal but you might choose to implement your own way of storing this information.

For this, the package uses the PortalStorage interface that defines the functions needed for the package.

By default, you'll simply wrap the Laravel session into a SessionPortalStorage:

Open portal

To open a portal into an account, simply call the openPortal method:

Please note that this will internally automatically check your defined gate and throw a "AccountPortalNotAllowedForUserException" if your gate denies the request.

Close portal

To close the portal, simply call closePortal with the current session

The second argument should be a callable that returns the model of a user by its ID. Internally, this package only stores the ID of the original user that opened the portal to get back to the account once the portal is closed. To stay unopinionated about your user modelling, you need to provide this callback to lookup the model by this saved ID.

Please note that this will throw a "NotInAccountPortalException" if the session doesn't currently have an active portal.

Portal status

To check the current status of the portal, you can use the helper methods isInPortal and canUsePortal:

Based on these parameters, you might choose to display an "Open account portal", "Close account portal" button or no button in your frontend.

Multi-level portal

Please note that due to security and complexity reasons, users cannot open a portal while already in a portal.

If a user is currently in a portal, canUsePortal will always return false, making it impossible to open further portals.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-account-portal with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^9.0
mockery/mockery Version ^1.5
spatie/laravel-package-tools Version ^1.9.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vantezzen/laravel-account-portal contains the following files

Loading the files please wait ....