Guest User

Untitled

a guest
Nov 8th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. public function create()
  2. {
  3. $this->form_validation->set_error_delimiters('','');
  4. $this->form_validation->set_rules( 'login' , 'Imię' , 'required|min_length[3]' );
  5. $this->form_validation->set_rules( 'email' , 'Email' , 'required|valid_email|is_unique[users.email]' );
  6. $this->form_validation->set_rules( 'password' , 'Hasło' , 'required|matches[passconf]' );
  7. $this->form_validation->set_rules( 'passconf' , 'Powtórz hasło' , 'required|matches[password]' );
  8.  
  9. if ( $this->form_validation->run())
  10. {
  11. $user = $this->input->post('user');
  12. unset($user['passconf']);
  13. $user['password'] = crypt($user['password'], config_item('encryption_key'));
  14. $this->Users_model->create($user);
  15. }
  16.  
  17. else
  18. {
  19. $errors['login'] = form_error( 'login' );
  20. $errors['email'] = form_error( 'email' );
  21. $errors['password'] = form_error( 'password' );
  22. $errors['passconf'] = form_error( 'passconf' );
  23. echo '{"records":' . json_encode( $errors ) . '}';
  24. }
  25.  
  26.  
  27. }
  28.  
  29. $scope.user = {};
  30. $scope.user.role = 'user';
  31.  
  32. $scope.createUser = function( user ){
  33. $http({
  34. method: 'POST', url: 'api/admin/users/create/' ,
  35. data: {
  36. user : user,
  37. login : user.login,
  38. email : user.email,
  39. password : user.password,
  40. passconf : user.passconf
  41. }}
  42. ).then(function ( errors ){
  43.  
  44. if ( errors )
  45. {
  46. $scope.errors = errors;
  47. }
  48. else
  49. {
  50. $scope.success = true;
  51. $timeout(function(){
  52. $scope.success = false;
  53. $scope.user = {};
  54. } , 3000 );
  55. }
  56.  
  57.  
  58. },function (error){
  59. console.log('Blad we wczytywaniu danych');
  60. });
  61. }
  62. });
Add Comment
Please, Sign In to add comment