imanghafoori/laravel-tokenize-login

v1.0.3 2020-06-01 13:21 UTC

This package is auto-updated.

Last update: 2020-08-31 13:53:01 UTC


README

Monthly Downloads Latest Stable Version Build Status Quality Score StyleCI Software License

This package creates an auto-expiring single-use 6 digit token, which you can send it (can be SMS, email, slack, etc ) to your users and they can login into their account with that token by just sending it back to an endpoint, which is also provided out of the box.

Exactly like alternate login method in Instagram.

You have complete control on how things will happen and you are free to swap the default implementations with your own.

Installation

composer require imanghafoori/laravel-tokenize-login

Then publish the config file:

php artisan vendor:publish

Basic usage:

Basically, this package introduces 2 endpoints, which you can send requests to them.

  1. The first one is to generate and send the token to the user
POST '/tokenized-login/request-token?email=iman@example.com'
  1. The second one accepts the token and authoenticates the user if the token was valid.
POST '/tokenized-login/login?email=iman@example.com'

Note: If you are not happy with the shape if the urls, you are free to cancel these out, and redefine them where ever you want. you can take a look at the source code to find the controllers they refer to.

To disable the default routes you may set: 'use_default_routes' => false, in the tokenized_login config file.

Customization:

You can do a lot of customization and swap the default classes, with your own altenatives since we use the larave-smart-facade package. Visit the config file to see what you can change.

If you want to swap the default implementations behind the facades with your own, you can do it within the boot method of any service provider class like this :

public function boot() 
{
     TokenStoreFacade::shouldProxyTo(MyTokenGenerator::class);
}

All the facades have a shouldProxyTo method which you can call, but remember not to do it within the register method, but only in boot.

🙋 Contributing

If you find an issue, or have a better way to do something, feel free to open an issue or a pull request. If you use laravel-widgetize in your open source project, create a pull request to provide it's url as a sample application in the README.md file.

❗ Security

If you discover any security related issues, please use the security tab instead of using the issue tracker.

⭐ Your Stars Make Us Do More ⭐

As always if you found this package useful and you want to encourage us to maintain and work on it. Just press the star button to declare your willing.

More from the author:

Laravel middlewarize

💎 You can put middleware on any method calls.

Laravel HeyMan

💎 It allows to write expressive code to authorize, validate and authenticate.

Laravel Terminator

💎 A minimal yet powerful package to give you opportunity to refactor your controllers.

🍌 Reward me a crypto-banana 🍌

so that I will have energy to start the next package for you.

  • Dodge Coin: DJEZr6GJ4Vx37LGF3zSng711AFZzmJTouN
  • LiteCoin: ltc1q82gnjkend684c5hvprg95fnja0ktjdfrhcu4c4
  • BitCoin: bc1q53dys3jkv0h4vhl88yqhqzyujvk35x8wad7uf9
  • Ripple: rJwrb2v1TR6rAHRWwcYvNZxjDN2bYpYXhZ
  • Etherium: 0xa4898246820bbC8f677A97C2B73e6DBB9510151e