•   Home  
  •   About  
  •   Login  
  •   Signup  
  •   Member  
  •   Staff  
This version is using user/security/login.
Make sure you go to level 5 and update the login to user/security/login and logout to user/security/logout.
  Step one: Create the website

Step one: Create the website

  • Use UCreate, select the wao file "Member with Yii2 RBAC", and click "Create Website"
  • Rename the URL and update the website
  • Disable the output of Yii2. Use ShortCut Yii2 -> yii2. This will reduce the update time.
  • default admin login:
    • user: admin
    • password:test1234
  Optional step two: Add Google Login

Optional step two: Add Google Login

  • Create an OAuth client ID,
    • Application type: Web application
    • Add Authorized JavaScript origins: URI https://yii2-rbac.asoneshare.com
    • Add Authorized redirect URI: https://yii2-rbac.asoneshare.com/
    • Download the Client ID and secret.
      • Client ID: 764997431754-xxxxsefiuejsin3d55sim270v15n54i0.apps.googleusercontent.com
      • Client secret: GOCSPX-mTWajrAlkxxxx-zzoC_Px1FzUwe1
    • Insert b_codeEditor into the area topD
      • Paste from https://website.webasone.com/default/en-US/nav6h3/WebApps/OpenSource/s/Yii2-Extra/GoogleLogin/index.php
      • Add shortCut "0 Yii2 | Google Login add on"
      • Click Composer, enter "../php/google", and click "Composer_install" to install Google PHP API libraries.
      • Click "Edit 1" to edit the gconfig.php
        • Replace the "Client ID" and "Client secret"
  • If Google login failed because of URI mismatch. Make sure the URI you enter at the Google console matches the URI while using "Edit 5" to edit the record logn.php. 
    • https://yii2-rbac.asoneshare.com and https://yii2-rbac.asoneshare.com/ are different. The second one ends with "/".
  Page roles access
  • Create a role at the website
    • Log in as admin to the website
    • Click the Admin page, click "New Roles"
  • To assign a user role
    • Log in as admin 
    • Click the edit icon to the right of a user
      • Click assignment
      • Select or delete items
      • Click Update assignment
  • Assign a role with access to a page
    • Log in to the management website
    • Go to level 5
    • For secondary navigation, use the layout screen to navigate to the target secondary page layout.
    • Navigate to Edit -> Menu -> EditMenu
    • Find the target page and click 
      • Enter the role and click AdddSessionVar
      • Assign as many roles as needed
  More customization

Accessiable to an area

  • click UpdateModuleVar1
  • To make this area accessable to the role Member
  • At Multi-PreTagCode (inlcuded before id div) enter "<?php if (yii_check("Member")) { ?> "
  • At the Multi-EndTagCode (Included after closing id div) enter "<?php } ?> "

Customize logout

  • Use ShortCut: 3.3 Navigation -> Nav
  • Add record Right-Code and enter
         <?php 
            // Check if the user is logged in 
            if (!Yii::$app->user->isGuest) { 
               // Get the user identity object 
               $identity = Yii::$app->user->identity; 
               // Access the email attribute 
               $userEmail = $identity->email; 
               // Use the email address 
               echo '<ul class="list-group list-group-flush">'; 
               echo '<li class="list-group-item" style="padding: 3px 5px;font-size: 80%;"><span>'. $userEmail.'</span></li>'; 
               echo '<li class="list-group-item text-center " style="padding: 1px 5px;font-size: 80%;"><a href="/default/en-US/nav6h0/s/Logout/?r=site%2Flogout">&nbsp;&nbsp;Logout&nbsp;&nbsp;</a></li></ul>'; 
           }
         ?>
            
Home  About  RegisteredUser  Login  Logout  Signup  Admin  Member  Staff 
Copyright © 2025 by My Company, All Rights Reserved