title: Set User Role in loopback using loopback-component-passport into inbuilt models
body: <p>I am trying to create user in loopback using npm <code>loopback-component-passport</code> with user roles based on a condition, </p>
  
  <ol>
  <li>If user is having property <code>isAdmin:true</code> he should have role of <code>admin</code></li>
  <li>If user is having property <code>isAdmin:false</code> he should have role of <code>user</code></li>
  </ol>
  
  <p>Here is my code:</p>
  
  <pre><code>if (form.$valid) {
          AuthService.register({
            name: $scope.user.name,
            email: $scope.user.email,
            password: $scope.user.password,
            isAdmin: $scope.user.isAdmin
          })
            .then(function() {
              // Account created, redirect to home
              $state.go('home');
            })
            .catch(function(err) {
              err = err.data;
              $scope.errors = {};
  
              // Update validity of form fields that match the mongoose errors
              angular.forEach(err.errors, function(error, field) {
                form[field].$setValidity('mongoose', false);
                $scope.errors[field] = error.message;
              });
          });
  }
  </code></pre>
  
  <p><strong>Factory:</strong></p>
  
  <pre><code>angular
    .module('app')
    .factory('AuthService', ['User', '$q', '$rootScope', function(User, $q, $rootScope) {
      function login(email, password) {
        return User
          .login({email: email, password: password})
          .$promise
          .then(function(response) {
            $rootScope.currentUser = {
              id: response.user.id,
              tokenId: response.id,
              email: email
            };
          });
      }
  
      function logout() {
        return User
          .logout()
          .$promise
          .then(function() {
            $rootScope.currentUser = null;
          });
      }
  
      function register(user) {
        return User.create(user).$promise;
      }
  
      return {
        login: login,
        logout: logout,
        register: register
      };
    }]);
  </code></pre>
  
  <p><strong>Passport strategy:</strong></p>
  
  <pre><code> "local": {
      "provider": "local",
      "module": "passport-local",
      "usernameField": "email",
      "passwordField": "password",
      "authPath": "/auth/local",
      "successRedirect": "/auth/account",
      "failureRedirect": "/local",
      "failureFlash": true
        },
     ... 
     ...
  </code></pre>
  
  <p><strong>model-config.json</strong></p>
  
  <pre><code>{ 
    "User": {
      "dataSource": "db"
    },
    "AccessToken": {
      "dataSource": "db",
      "public": false
    },
    "ACL": {
      "dataSource": "db",
      "public": false
    },
    "RoleMapping": {
      "dataSource": "db",
      "public": false
    },
    "Role": {
      "dataSource": "db",
      "public": false
    }
  }
  </code></pre>
  
  <p>But now I have no clue how to add role so that I can differentiate users with user roles. How can I set user roles in <code>loopback-component-passport</code>'s inbuilt model?</p>