Create an approved 'global' administrator

        :param email: the user's email address
        :param password: the user's plain text password
        :returns: a User
488006
def create_admin(cls, email, password, **kwargs):
        
        data = {
            'email': email,
            'password': cls.hash_password(password),
            'has_agreed_to_terms': True,
            'state': State.approved,
            'role': cls.roles.administrator.value,
            'organisations': {}
        }
        data.update(**kwargs)

        user = cls(**data)
        yield user._save()

        raise Return(user)
1066793
def GetUserByEmail(self, email):
    
    user = self.rpc_helper.GetAccountInfoByEmail(email)
    return GitkitUser.FromApiResponse(user)
917827
def auth_user_oid(self, email):
        
        user = self.find_user(email=email)
        if user is None or (not user.is_active):
            log.info(LOGMSG_WAR_SEC_LOGIN_FAILED.format(email))
            return None
        else:
            self.update_user_auth_stat(user)
            return user
10418
public com.authy.api.User createUser(String email, String phone) {
		return createUser(email, phone, DEFAULT_COUNTRY_CODE);
	}
837207
public static SignInResponse signIn(String email, String password){
        return signIn(new LoginCredentials(email,password));
    }
771856
def create_superuser(
            self, username, email, short_name, full_name,
            institute, password, **extra_fields):
        
        return self._create_user(
            username=username, email=email,
            institute=institute, password=password,
            short_name=short_name, full_name=full_name,
            is_admin=True, **extra_fields)
189692
def send_activation_email(self, user, profile, password, site):
        
        ctx_dict = { 'password': password, 
                     'site': site, 
                     'activation_key': profile.activation_key,
                     'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS}
                     
        subject = render_to_string(
            'registration/email/emails/password_subject.txt',
            ctx_dict)
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())
        
        message = render_to_string('registration/email/emails/password.txt',
                                   ctx_dict)
                                   
        try:
            user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
        except:
            pass
887814
def global_permission_set(self):
        ''''''
        only_admins_create_admins = Or(
            AllowAdmin,
            And(
                ObjAttrTrue(
                    lambda r, _: r.data.get('admin') is not True),
                Or(
                    AllowPermission('org:admin')
                )
            )
        )

        return And(
            AllowOnlyAuthenticated,
            Or(
                Not(AllowCreate),
                only_admins_create_admins
            )
        )
152025
def register_by_email(self, email, sender=None, request=None, **kwargs):
        
        try:
            user = self.user_model.objects.get(email=email)
        except self.user_model.DoesNotExist:
            user = self.user_model.objects.create(
                username=self.get_username(),
                email=email,
                password=self.user_model.objects.make_random_password(),
            )
            user.is_active = False
            user.save()
        self.send_activation(user, sender, **kwargs)
        return user
889752
def create_user(cls, username, password, name, email):
        """"""
        config = Config()
        payload = {"username": username,
                   "email": email,
                   "name": name,
                   "password": password, }
        user_creation_resp = requests.post("https://users.{}/users/".format(config.host),
                                           json=payload)
        if user_creation_resp.status_code != 201:
            raise errors.ResourceError("couldnt create user")
992214
def create(self, email, phone, country_code=1, send_install_link_via_sms=False):
        
        data = {
            "user": {
                "email": email,
                "cellphone": phone,
                "country_code": country_code
            },

            'send_install_link_via_sms': send_install_link_via_sms
        }

        resp = self.post("/protected/json/users/new", data)

        return User(self, resp)
1333655
def login(self, email=None, password=None):
        """"""
        auth_url = self.url('auth')
        email = email or self._config.get('email')
        password = password or self._config.get('password')
        if password and not email:
            raise Exception('Email must be provided when password is.')
        while True:
            if not email:
                sys.stdout.write('Email: ')
                sys.stdout.flush()
                email = sys.stdin.readline().strip()
                if not email:
                    print('Goodbye!')
                    sys.exit(1)
            if not password:
                password = getpass.getpass('Password for {0}: '.format(email))
            response = self.request(auth_url, 'PUT', email=email,
                                    password=password)
            if response.status_code == 201:
                print('logged in as {0}'.format(email))
                self.save_prompt(email, password)
                self.email = email
                break
            else:
                print(response.json()['messages'])
                email = password = None
729382
def create(gandi, email, quota, fallback, alias, password):
    """"""
    login, domain = email
    options = {}

    if not password:
        password = click.prompt('password', hide_input=True,
                                confirmation_prompt=True)
    options['password'] = password
    if quota is not None:
        options['quota'] = quota
    if fallback is not None:
        options['fallback_email'] = fallback

    result = gandi.mail.create(domain, login, options, alias)

    return result
1258599
def add_administrator(self, project_id, name, email):
        
        self._run(
            url_path="contributors/add",
            id=project_id,
            name=name,
            email=email,
            admin=True
        )
        return True
313114
def check_auth(email, password):
    
    try:
        user = User.get(User.email == email)
    except User.DoesNotExist:
        return False
    return password == user.password
6126
def get_or_create_user(self, username, password):
        '''
        
        '''

        # Get the groups for this user
        info = self.get_ad_info(username, password)
        self.debug("INFO found: {}".format(info))

        # Find the user
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            user = User(username=username)

        # Update user
        user.first_name = info.get('first_name', '')
        user.last_name = info.get('last_name', '')
        user.email = info.get('email', '')

        # Check if the user is in the Administrators groups
        is_admin = False
        for domain in info['groups']:
            if 'Domain Admins' in info['groups'][domain]:
                is_admin = True
                break

        # Set the user permissions
        user.is_staff = is_admin
        user.is_superuser = is_admin

        # Refresh the password
        user.set_password(password)

        # Validate the selected user and gotten information
        user = self.validate(user, info)
        if user:
            self.debug("User got validated!")

            # Autosave the user until this point
            user.save()

            # Synchronize user
            self.synchronize(user, info)
        else:
            self.debug("User didn't pass validation!")

        # Finally return user
        return user
1069746
def create_user(backend, details, response, uid, username, user=None, *args, **kwargs):
    
    if user:
        return {'user': user}
    if not username:
        return None
    email = details.get('email')
    original_email = None
    # email is required
    if not email:
        message = _("""your social account needs to have a verified email address in order to proceed.""")
        raise AuthFailed(backend, message)
    # Avoid hitting field max length
    if email and len(email) > 75:
        original_email = email
        email = ''
    return {
        'user': UserSocialAuth.create_user(username=username,
                                           email=email,
                                           sync_emailaddress=False),
        'original_email': original_email,
        'is_new': True
    }