maksuco/bizauth

Installs: 85

Dependents: 0

Suggesters: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:laravel

V1.4.1.2 2019-10-07 16:22 UTC

README

Private package to handle user logins sessions, roles (Staff), remember password, confirm email and Socialite

Installation

You can install the package via composer:

composer require maksuco/bizauth

This Package works with auto discovery in Laravel +5.5, but is compatible with older versions

Migrations

php artisan migrate

Publish config

php artisan vendor:publish

Config

Please make sure server time and laravel are the same, this fixes login error in safari.

Change emails designs

first run: php artisan vendor:publish --tag=laravel-mail if you don't publish, laravel will use the one on the package, that cant be re designed add this to your vendor/layout

<style>
    <?php include public_path('assets/css/markdown-email.css') ?>
</style>

Confirm Email and Log User Logins

Just change it in the config file

Slack Notifications

To get notificcations of new users by slack, just put this on your .env file and set 'notify_slack' => true in the config file SLACK_HOOK='https://hooks.slack.com/services/xxxxxxx'

Activate logout of all devices

See info

Socialite Configuration

please put this in config/services

'facebook' => [
    'client_id' => 'xxxxx',
    'client_secret' => env('FACEBOOK_SECRET'),
    'redirect' => env('APP_URL').'/register-facebook',
],
'google' => [
  'client_id' => '9xxxxxxx',
  'client_secret' => env('GOOGLE_SECRET'),
    'redirect' => env('APP_URL').'/register-google',
    'maps' => [
        'api-key' => 'xxxxxxxxx',
    ],
],

Usage

Middleware/RedirectIfAuthenticated

Put this code in the RedirectIfAuthenticated file to allow redirects at login

if (Auth::guard($guard)->check() AND session()->has('redirect')) {
    $redirect = session()->get('redirect');
    session()->forget('redirect');
    return redirect($redirect);
}

Staff and Roles

Staff Roles return true or false ,it automatically redirects to the previews page with error message __('staff_not_allowed_to') //Missing subtable

JSON SAMPLE: 
{
  "pages": {
    "show": true,
    "store": false,
    "update": false,
    "index": true,
    "destroy": true
  },
  "settings": {
    "show": false,
    "update": false
  },
  "news": {
    "events": {
      "id": 6,
      "name": "Events",
      "show": true,
      "store": false,
      "update": false,
      "index": true,
      "destroy": true
    }
  }
}
//ACTIONS: index, store, show, update, destroy and any one you want
\BizAuth::biz_staff_roles($user, $biz, 'table', 'show'); //returns true or redirects back
\BizAuth::biz_staff_roles($user, $biz, 'table', 'show','dontredirect'); //returns true or false
\BizAuth::biz_staff_roles($user, $biz, 'news->events', 'update'); //with sub tables

Check if manager or admin

Checks if the auth user, is manager or admin, useful for settings for example

//$type is 'manager' or 'admin'
\BizAuth::check($biz); //returns true or false
\BizAuth::check($biz, $type); //If you want to check admin, returns true or false

To clean record/log logins

To clean up the login files and leave a max of 15 entries per user, use this artisan command

php artisan bizauth:userlogin-cleanup

API for mobile devices

Xxxxxx

Login

xxxxx

Register

xxxxx