Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function create()
- {
- $this->form_validation->set_error_delimiters('','');
- $this->form_validation->set_rules( 'login' , 'Imię' , 'required|min_length[3]' );
- $this->form_validation->set_rules( 'email' , 'Email' , 'required|valid_email|is_unique[users.email]' );
- $this->form_validation->set_rules( 'password' , 'Hasło' , 'required|matches[passconf]' );
- $this->form_validation->set_rules( 'passconf' , 'Powtórz hasło' , 'required|matches[password]' );
- if ( $this->form_validation->run())
- {
- $user = $this->input->post('user');
- unset($user['passconf']);
- $user['password'] = crypt($user['password'], config_item('encryption_key'));
- $this->Users_model->create($user);
- }
- else
- {
- $errors['login'] = form_error( 'login' );
- $errors['email'] = form_error( 'email' );
- $errors['password'] = form_error( 'password' );
- $errors['passconf'] = form_error( 'passconf' );
- echo '{"records":' . json_encode( $errors ) . '}';
- }
- }
- $scope.user = {};
- $scope.user.role = 'user';
- $scope.createUser = function( user ){
- $http({
- method: 'POST', url: 'api/admin/users/create/' ,
- data: {
- user : user,
- login : user.login,
- email : user.email,
- password : user.password,
- passconf : user.passconf
- }}
- ).then(function ( errors ){
- if ( errors )
- {
- $scope.errors = errors;
- }
- else
- {
- $scope.success = true;
- $timeout(function(){
- $scope.success = false;
- $scope.user = {};
- } , 3000 );
- }
- },function (error){
- console.log('Blad we wczytywaniu danych');
- });
- }
- });
Add Comment
Please, Sign In to add comment