newUser.js 662 B

12345678910111213141516171819202122232425
  1. /*
  2. Create a new User
  3. This example demonstrate the agi script to create a new user
  4. REQUIRE ADMIN PERMISSION
  5. */
  6. if (userIsAdmin() == false){
  7. //Not admin. Reject request
  8. sendResp("Require admin permission to create user")
  9. }else{
  10. //Try to creat a new user call Dummy
  11. if (userExists("YamiOdymel")){
  12. sendResp("User Already Exists!");
  13. }else{
  14. //Create the user if not exists
  15. var success = createUser("YamiOdymel", "123456", "default");
  16. if (success){
  17. sendResp("User Creation Succeed");
  18. }else{
  19. sendResp("User Creation failed. See terminal for more info.")
  20. }
  21. }
  22. }