RADIUSdesk

logo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
radiusdesk:login_pages:other_profile [2023/01/25 22:56]
admin [User Registration - Other Profile Option]
radiusdesk:login_pages:other_profile [2023/01/25 23:11] (current)
admin [Tweak sConnect.js]
Line 1: Line 1:
 ====== User Registration - Other Profile Option ====== ====== User Registration - Other Profile Option ======
-   * When User Registration is configured on a Login Page you have to define a Profile and Realm the registered user will be assigned to. +   * When User Registration is configured on a Login Page you define a **Profile** and **Realm** the registered user will be assigned to. 
-   * There might however be times that you want to assign the user to a different profile (for whatever reason)+   * There might however be times that you want to assign the user to a different profile (for whatever reason).
    * We have added this **hidden** feature and documented it here.    * We have added this **hidden** feature and documented it here.
 ===== Create other profile ===== ===== Create other profile =====
   * Make sure you create the other profile and it has all the features you need (e.g. faster bandwidth)   * Make sure you create the other profile and it has all the features you need (e.g. faster bandwidth)
   * You can use the Profile name or Profile ID in the Login Page.   * You can use the Profile name or Profile ID in the Login Page.
 +
 +===== Tweak sConnect.js =====
 +  * In our example we will reward users that register with a phone number that starts with **083** and has a total of 10 digits.
 +  * Edit **/var/www/html/login/bootstrap5/js/sConnect.js**.
 +  * Look for this part:
 +<code javascript>
 +/*  
 +                //=== Proof of Concept Hack ===
 +                //=== other_profile_name = 'Dev_Super_Register'
 +                var other_profile_name = 'Dev_Super_Register';
 +                //var other_profile_id = 56; //Alternative
 +                var phone   = $("#txtrCell").val();
 +                if(/^072/.test(phone)){
 +                    formData['other_profile_name' = other_profile_name;
 +                    //formData['other_profile_id'   = other_profile_id;
 +                }
 +                //=== END Proof of Concept Hack === 
 +*/              
 +</code>
 +  * Now for our requirement we change it to the following:
 +<code javascript>
 +//=== Proof of Concept Hack ===
 +//=== other_profile_name = 'Dev_Super_Register'
 +    var other_profile_name = 'MTN-Profile';
 +    //var other_profile_id = 56; //Alternative
 +    var phone   = $("#txtrCell").val();
 +    if(/^083\d{7}$/.test(phone)){
 +        formData['other_profile_name' = other_profile_name;
 +        //formData['other_profile_id'   = other_profile_id;
 +     }
 +//=== END Proof of Concept Hack ===
 +</code>
 +  * This means that if during registration a match on the phone number requirement is found, the user will be registered with the other profile.
 +  * You can create your own criteria and simply tweak the **sConnect.js** file.
 +  * This feature comes in handy if you want to give certain users special treatment based on the value of one of the supplied fields during user registration.
 +