Example #1
0
    def txn():
      key_name = cls.get_key_name(user_name)
      user = cls.get_by_key_name(key_name)
      if user:
        from kay.auth import DuplicateKeyError
        raise DuplicateKeyError(_(u"This user name is already taken."
                                  " Please choose another user name."))
      if do_registration:
        salt = crypto.gen_salt()
        activation_key = crypto.sha1(salt+user_name).hexdigest()
        profile_key = db.Key.from_path(cls.kind(), key_name,
                                       RegistrationProfile.kind(),
                                       activation_key)

        expiration_date = datetime.datetime.now() + \
            datetime.timedelta(seconds=settings.ACCOUNT_ACTIVATION_DURATION)
        user = cls(key_name=key_name, activated=False, user_name=user_name,
                   password=crypto.gen_pwhash(password), email=email, **kwargs)
        taskqueue.add(url=url_for('_internal/expire_registration',
                                  registration_key=str(profile_key)),
                      eta=expiration_date, transactional=True)
        taskqueue.add(url=url_for('_internal/send_registration_confirm',
                                  registration_key=str(profile_key)),
                      transactional=True)
        profile = RegistrationProfile(user=user, parent=user,
                                      key_name=activation_key)
        db.put([profile, user])
      else:
        user = cls(key_name=key_name, activated=False, user_name=user_name,
                   password=crypto.gen_pwhash(password), email=email)
        db.put(user)
      return user
Example #2
0
        def txn():
            key_name = cls.get_key_name(user_name)
            user = cls.get_by_key_name(key_name)
            if user:
                from kay.auth import DuplicateKeyError
                raise DuplicateKeyError(
                    _(u"This user name is already taken."
                      " Please choose another user name."))
            salt = crypto.gen_salt()
            activation_key = crypto.sha1(salt + user_name).hexdigest()
            profile_key = db.Key.from_path(cls.kind(), key_name,
                                           RegistrationProfile.kind(),
                                           activation_key)

            expiration_date = datetime.datetime.now() + \
                datetime.timedelta(seconds=settings.ACCOUNT_ACTIVATION_DURATION)
            taskqueue.add(url=url_for('_internal/expire_registration',
                                      registration_key=str(profile_key)),
                          eta=expiration_date,
                          transactional=True)
            taskqueue.add(url=url_for('_internal/send_registration_confirm',
                                      registration_key=str(profile_key)),
                          transactional=True)
            user = cls(key_name=key_name,
                       activated=False,
                       user_name=user_name,
                       password=crypto.gen_pwhash(password),
                       email=email)
            profile = RegistrationProfile(user=user,
                                          parent=user,
                                          key_name=activation_key)
            db.put([profile, user])
            return user
Example #3
0
 def txn():
     reg_request_obj = RegistrationRequest(
         first_name=request.form["first_name"],
         email=request.form["email"],
         telephone=request.form["telephone"],
         company=request.form["company"],
         password=crypto.gen_pwhash(request.form["password"]),
         manager=db.Key(request.form.get("manager")),
     )
     reg_request_obj.put()
     taskqueue.add(
         url=url_for("auth5/send_request_to_manager", request_key=str(reg_request_obj.key())),
         transactional=True,
     )
Example #4
0
 def hash_password(cls, raw):
   return crypto.gen_pwhash(raw)
Example #5
0
 def hash_password(cls, raw):
     return crypto.gen_pwhash(raw)