Ejemplo n.º 1
0
 def post(self):
     username = self.request.get('username')
     password = self.request.get('password')
     verify = self.request.get('verify')
     email = self.request.get('email')
     user = User.by_name(username)
     values = {}
     if not u.valid_username(username):
         values['error_username'] = "******"
     if user:
         values['error_username2'] = "Username already exists."
     if not u.valid_password(password):
         values['error_password'] = "******"
     if password != verify:
         values['error_verify'] = "Your passwords didn't match."
     if not u.valid_email(email):
         values['error_email'] = "That's not a valid email."
     if values:
         values.update({'username' : username, 'email' : email})
         self.markup('signup.html', **values)
     else:
         password_hashed = u.make_password_hash(username, password)
         user = User(username = username, password_hashed = password_hashed, email = email)
         user.put()
         self.set_cookie("user_id", str(user.key().id()))
         self.redirect("/dashboard")
Ejemplo n.º 2
0
 def set_password(self, user_id, raw_password):
     from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper
     connection = DatabaseWrapper(self.database_settings)
     cursor = connection.cursor()
     password = utils.make_password_hash(raw_password)
     cursor.execute("UPDATE %s SET password=%%s WHERE id=%%s" % self.model._meta.db_table,
         (password, user_id))
     connection._commit()
     connection.close()
Ejemplo n.º 3
0
 def set_password(self, user_id, raw_password):
     from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper
     connection = DatabaseWrapper(self.database_settings)
     cursor = connection.cursor()
     password = utils.make_password_hash(raw_password)
     cursor.execute(
         "UPDATE %s SET password=%%s WHERE id=%%s" %
         self.model._meta.db_table, (password, user_id))
     connection._commit()
     connection.close()
Ejemplo n.º 4
0
 def create_user(self, **kwargs):
     from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper
     connection = DatabaseWrapper(self.database_settings)
     cursor = connection.cursor()
     opts = self.model._meta
     fields = [f for f in opts.fields if f.name != 'id']
     try:
         kwargs['password'] = utils.make_password_hash(kwargs['password'])
         values = [kwargs[f.name] for f in fields]
     except KeyError, e:
         raise ValueError('Missing field: %s' % e)
Ejemplo n.º 5
0
 def create_user(self, **kwargs):
     from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper
     connection = DatabaseWrapper(self.database_settings)
     cursor = connection.cursor()
     opts = self.model._meta
     fields = [f for f in opts.fields if f.name != 'id']
     try:
         kwargs['password'] = utils.make_password_hash(kwargs['password'])
         values = [kwargs[f.name] for f in fields]
     except KeyError, e:
         raise ValueError('Missing field: %s' % e)
Ejemplo n.º 6
0
 def register(cls, username, password, email=None):
     password_hash = make_password_hash(username, password)
     return User(parent=users_key(),
                 username=username,
                 password_hash=password_hash,
                 email=email)
Ejemplo n.º 7
0
 def register(cls, name, password, email=None):
     password_hash = utils.make_password_hash(name, password)
     return User(parent=users_key(), name=name, password_hash=password_hash,
                 email=email)
Ejemplo n.º 8
0
 def register(cls, name, password, email = None, puntaje = 0):
     pw_hash = utils.make_password_hash(name, password)
     u = cls(name = name, password_hash = pw_hash, puntaje = puntaje)
     if email:
         u.email = email
     return u
Ejemplo n.º 9
0
 def set_password(self, new_password):
     self.password = utils.make_password_hash(new_password)
Ejemplo n.º 10
0
 def set_password(self, new_password):
     self.password = utils.make_password_hash(new_password)