Step 3b. Create a new user account or return an existing one.
435781
function (req, res, next) {
    var profile = req.profile;
    var filter = { or: [{ yahoo: profile.guid }, { email: profile.email }] };

    User.find({ where: filter }, function(err, users) {
      var user = users[0];

      if (user) {
        if (!user.yahoo) {
          user.yahoo = body.profile.guid;
          user.displayName = user.displayName || body.profile.name;
          user.save(function() {
            req.user = user;
            next();
          });
          return;
        }

        req.user = user;
        next();
        return;
      }

      User.create({
        displayName: body.profile.name,
        yahoo: body.profile.guid,
        email: body.profile.email,
        password: body.profile.guid
      }, function (err, user) {
        req.user = user;
        next();
      });

    });
  }
189671
def save(self):
        
        username, email, password = (self.cleaned_data['username'],
                                     self.cleaned_data['email'],
                                     self.cleaned_data['password1'])

        new_user = UserenaSignup.objects.create_user(username,
                                                     email,
                                                     password,
                                                     not userena_settings.USERENA_ACTIVATION_REQUIRED,
                                                     userena_settings.USERENA_ACTIVATION_REQUIRED)
        return new_user
1080749
def create_user(self, name, password):
        """"""
        hashed_password = self._password_hasher(password)
        return dict(name=name, password=hashed_password)
860819
def get_iam_account(l, args, user_name):
    

    iam = get_resource(args, 'iam')
    user = iam.User(user_name)
    user.load()

    return l.find_or_new_account(user.arn)
86049
def create_account(self, **params):
        """"""
        response = self._post('v2', 'accounts', data=params)
        return self._make_api_object(response, Account)
1111460
public User createUser(final User user) throws UnauthorizedException {
        User requestingUser = getCurrentUser();
        if (requestingUser != null && !requestingUser.isAdmin()) {
            throw new UnauthorizedException("Only admins can create new accounts!");
        }
        tt.execute(new TransactionCallbackWithoutResult() {
            public void doInTransactionWithoutResult(TransactionStatus status) {
                boolean success = false;
                try {
                    PasswordEncoder encoder = new ShaPasswordEncoder();
                    String hashedPass = encoder.encodePassword(user.getPassword(), null);
                    user.setId(insert(
                            "INSERT INTO Users (username, password, enabled) "
                            + "VALUES (?, ?, ?)", user.getName(),
                            hashedPass, user.isEnabled()));
                    addAuthority(user.getName(), ROLE_USER);
                    if (user.isAdmin()) {
                        addAuthority(user.getName(), ROLE_ADMIN);
                    }
                    success = true;
                } finally {
                    if (!success) {
                        status.setRollbackOnly();
                    }
                }
            }
        });
        return user;
    }
1112401
def create_user(name,
                username,
                email,
                password,
                token_manager=None,
                app_url=defaults.APP_URL):
    
    headers = token_manager.get_access_token_headers()
    auth_url = environment.get_auth_url(app_url=app_url)
    url = "%s/api/v1/accounts" % auth_url

    payload = {
        'name': name,
        'username': username,
        'email': email,
        'password': password
    }

    response = requests.post(url,
                             data=json.dumps(payload),
                             headers=headers)

    if response.status_code == 201:
        return response.json()

    else:
        raise JutException('Error %s: %s' % (response.status_code, response.text))
1189052
def create(self, id):
        
        resp = self.client.accounts.create(id=id)
        self.display(resp)
247785
def create_user(self, **kwargs):
        """"""
        kwargs = self._prepare_create_user_args(**kwargs)
        user = self.user_model(**kwargs)
        return self.put(user)
566949
function create(user, callback) {
      var cb = callback || angular.noop;

      return User.create(user,
        function (user) {
          return cb(user);
        },
        function (err) {
          return cb(err);
        }).$promise;
    }
4060
def create
      if (@user = Incline::UserManager.authenticate(params[:session][:email], params[:session][:password], request.remote_ip))
        if @user.activated?
          # log the user in.
          log_in @user
          params[:session][:remember_me] == '1' ? remember(@user) : forget(@user)

          # show alerts on login.
          session[:show_alerts] = true

          redirect_back_or @user
        else
          flash[:safe_warning] = 'Your account has not yet been activated.<br/>Check your email for the activation link.'
          redirect_to main_app.root_url
        end
      else
        # deny login.
        flash.now[:danger] = 'Invalid email or password.'
        render 'new'
      end
    end
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)
382235
def add_user(self, name: str, email: str) -> models.User:
        """"""
        new_user = self.User(name=name, email=email)
        self.add_commit(new_user)
        return new_user
1028864
def create_user(
            self, username, email, short_name, full_name,
            institute, password=None, **extra_fields):
        
        return self._create_user(
            username=username, email=email,
            short_name=short_name, full_name=full_name,
            institute=institute, password=password,
            is_admin=False, **extra_fields)
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
    }
540075
def get_or_create_user(self, access_token, id_token, payload):
        """"""

        user_info = self.get_userinfo(access_token, id_token, payload)

        email = user_info.get('email')

        claims_verified = self.verify_claims(user_info)
        if not claims_verified:
            msg = 'Claims verification failed'
            raise SuspiciousOperation(msg)

        # email based filtering
        users = self.filter_users_by_claims(user_info)

        if len(users) == 1:
            return self.update_user(users[0], user_info)
        elif len(users) > 1:
            # In the rare case that two user accounts have the same email address,
            # bail. Randomly selecting one seems really wrong.
            msg = 'Multiple users returned'
            raise SuspiciousOperation(msg)
        elif self.get_settings('OIDC_CREATE_USER', True):
            user = self.create_user(user_info)
            return user
        else:
            LOGGER.debug('Login failed: No user with email %s found, and '
                         'OIDC_CREATE_USER is False', email)
            return None
325317
function createUser (req, res, next) {
    User.insert(req.body, { private: true }, function (err, user) {
      if (err) {
        res.render('signup', {
          params: qs.stringify(req.body),
          request: req.body,
          providers: settings.providers,
          error: err.message
        })
      } else {
        authenticator.dispatch('password', req, res, next, function (err, user, info) {
          if (err) { return next(err) }
          if (!user) {
          } else {
            authenticator.login(req, user)
            req.sendVerificationEmail =
              req.provider.emailVerification.enable
            req.flash('isNewUser', true)
            next()
          }
        })
      }
    })
  }