(data)
| 657 | |
| 658 | |
| 659 | def create_user(data): |
| 660 | if 'auth_source' in data and data['auth_source'] != \ |
| 661 | INTERNAL: |
| 662 | req_params = ('username', 'role', 'active', 'auth_source') |
| 663 | else: |
| 664 | req_params = ('email', 'role', 'active', 'newPassword', |
| 665 | 'confirmPassword') |
| 666 | |
| 667 | for f in req_params: |
| 668 | if f in data and data[f] != '': |
| 669 | continue |
| 670 | else: |
| 671 | return False, _("Missing field: '{0}'").format(f) |
| 672 | |
| 673 | data['auth_source'] = data['auth_source'] if 'auth_source' in data \ |
| 674 | else INTERNAL |
| 675 | data['username'] = data['username'] if \ |
| 676 | 'username' in data and data['auth_source'] != \ |
| 677 | INTERNAL else data['email'] |
| 678 | data['email'] = data['email'] if 'email' in data else None |
| 679 | data['password'] = data['password'] if 'password' in data else None |
| 680 | |
| 681 | try: |
| 682 | new_data = validate_user(data) |
| 683 | new_data['email'] = new_data['email'] if 'email' in new_data else None |
| 684 | new_data['password'] = new_data['password']\ |
| 685 | if 'password' in new_data else None |
| 686 | |
| 687 | if 'roles' in new_data: |
| 688 | new_data['roles'] = [Role.query.get(new_data['roles'])] |
| 689 | |
| 690 | except Exception as e: |
| 691 | return False, str(e) |
| 692 | |
| 693 | try: |
| 694 | _create_new_user(new_data) |
| 695 | except Exception as e: |
| 696 | return False, str(e) |
| 697 | |
| 698 | # Create users storage directory |
| 699 | create_users_storage_directory() |
| 700 | |
| 701 | return True, '' |
| 702 | |
| 703 | |
| 704 | def update_user(uid, data): |
no test coverage detected