I think you just need: db.users.password.requires = [IS_NOT_EMPTY(), CRYPT()]
On Feb 24, 2:48 am, Jason Brower <encomp...@gmail.com> wrote: > I have the system setup, thanks to the help of a polish friend, and it > seems to successfully register new users into the database. The issue > lies in my login. It seems that the data itself it saved, but I notice > that the password is set a string. It is not hashed. > I think this is where the problem is, but I could be totally wrong. > So is there something I am doing wrong here? > I am running the latest trunk code. > The following is the db.py file. > ----- > #!/usr/bin/python > # -*- coding: utf-8 -*- > import datetime > from gluon.tools import Mail, Auth, Recaptcha > from gluon.tools import Crud > # System Variables > now = datetime.date.today() > #Create the database connection > db = SQLDB('sqlite://interestID.db') > mail=Mail() > ## specify your SMTP server > mail.settings.server = 'smtp.gmail.com:25' > ## specify your email address > mail.settings.sender = 'encomp...@gmail.com' > ## optional: specify the username and password for SMTP > mail.settings.login = 'encomp...@------' > ## instantiate the Auth class (or your derived class) > crud = Crud(globals(),db) > ## optional: require email verification for registration > # auth.settings.mailer = mail > ## optional: if you require captcha verification for registration > # auth.settings.captcha = > Recaptcha(request,public_key='RECAPTCHA_PUBLIC_KEY',private_key='RECAPTCHA_PRIVATE_KEY') > # Create the user table > db.define_table('users', > SQLField('nickname', length=25), > SQLField('email', 'string'), > SQLField('first_name', 'string'), > SQLField('last_name', 'string'), > SQLField('password', 'password'), > SQLField('created', 'date', default=now), > SQLField('deleted', 'string'), > SQLField('verified', 'boolean', default= False), > SQLField('position', 'string'), > SQLField('profile_text', 'text'), > SQLField('profile_photo', 'upload', default=''), > SQLField('homepage', 'string'), > SQLField('event','string'), > SQLField('registration_key', length=128, > writable=False, readable=False), > ) > > #Setup the users table > db.users.nickname.requires = [IS_NOT_IN_DB(db, 'users.nickname')] > db.users.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db, 'users.email')] > db.users.first_name.requires = IS_NOT_EMPTY() > db.users.last_name.requires = IS_NOT_EMPTY() > db.users.password.requires = IS_NOT_EMPTY() > db.users.position.requires = IS_NOT_EMPTY() > db.users.nickname.requires = IS_NOT_EMPTY() > > class MyAuth(Auth): > def __init__(self, environment, T, db = None): > "Initialise parent class & make any necessary modifications" > Auth.__init__(self,environment,db) > self.messages.logged_in = T("Logged in") > self.messages.email_sent = T("Email sent") > self.messages.email_verified = T("Email verified") > self.messages.logged_out = T("Logged out") > self.messages.registration_successful = T("Registration > successful") > self.messages.invalid_email = T("Invalid email") > self.messages.invalid_login = T("Invalid login") > self.messages.verify_email_subject = T("Password verify") > self.messages.username_sent = T("Your username was emailed to > you") > self.messages.new_password_sent = T("A new password was emailed > to you") > self.messages.invalid_email = T("Invalid email") > self.messages.password_changed = T("Password changed") > self.messages.retrieve_username=str(T("Your username is"))+": > %(username)s" > self.messages.retrieve_username_subject="Username retrieve" > self.messages.retrieve_password=str(T("Your password is"))+": > %(password)s" > self.messages.retrieve_password_subject = T("Password retrieve") > self.messages.profile_updated = T("Profile updated") > #Use my own table instead of the default table. > self.settings.table_user=db.users > > #Create groups for the authenticated users > #The current list is not real, but just some ideas to fill space. > #positions = {'Administrator' : 'Add and Remove users. Creates > events.', > # 'Vistor' : 'Can view information about events and > tags.', > # 'Speaker' : 'Can create special tags and > schedules', > # 'Guest' : 'Can view information about the > event.', > # 'Staff' : 'Can edit the room and booth locations > and information', > # 'Booth' : 'Can create a booth profile and add > prizes', > # 'Room' : 'Can create a schedule for the room'} > #for role_id in positions.keys(): > # group_id = auth.add_group(role = role_id, description = > positions[role_id]) > > auth = MyAuth(globals(), T, db) > ## ask it to create all necessary tables > auth.define_tables() > > db.define_table('tagCloud', > SQLField('creator','string'), > SQLField('name','string'), > SQLField('description','text'), > SQLField('created','date', default=now), > SQLField('logo_picture','upload', default='')) > > #Setup the tagCloud table > db.tagCloud.creator.requires = IS_IN_DB(db, 'users.id', > 'users.nickname') > db.tagCloud.name.requires = IS_NOT_EMPTY() > db.tagCloud.logo_picture.requires = IS_NOT_EMPTY() > > db.define_table('tag', > SQLField('tag_id',db.tagCloud), > SQLField('personalRating','integer')) > > db.tag.tag_id.requires = IS_IN_DB(db, 'tagCloud.id', 'tagCloud.name') > > db.define_table('emailMessages', > SQLField('from_nickname','string'), > SQLField('to_nickname','string'), > SQLField('recieved','date', default=now), > SQLField('subject','string'), > SQLField('email_text','text'), > SQLField('thread', 'integer')) > > #Setup the emailMessages table > db.emailMessages.subject.requires = [IS_NOT_EMPTY()] > db.emailMessages.from_nickname.requires = > IS_IN_DB(db,'users.id','users.nickname') > db.emailMessages.to_nickname.requires = > IS_IN_DB(db,'users.id','users.nickname') > db.emailMessages.recieved.requires = [IS_NOT_EMPTY()] > db.emailMessages.email_text.requires = [IS_NOT_EMPTY()] > > #A building can have many rooms > db.define_table('rooms', > SQLField('roomName','string'), > SQLField('capacity','integer'), > SQLField('description','text'), > SQLField('projector','boolean', default= False), > SQLField('whiteboard','boolean', default= False), > SQLField('amps','boolean', default= False), > SQLField('tables','boolean', default= False), > SQLField('chairs','boolean', default= False), > SQLField('wInternet','boolean', default= False), > SQLField('width','integer', default=0), > SQLField('length','integer', default=0), > SQLField('scale','string', default="meters"), > SQLField('building','string')) > > #Creating an event > db.define_table('events', > SQLField('eventName','string'), > SQLField('address','string'), > SQLField('phone','string'), > SQLField('email','string'), > SQLField('logo','string'), > SQLField('startDate', 'date'), > SQLField('endDate','date')) > > #An event can have many rooms > db.define_table('neededRooms', > SQLField('event','string'), > SQLField('room','string')) > > #A room can have many sessions > #But those times should not over lap > db.define_table('session', > SQLField('name','string'), > SQLField('date','string'), > SQLField('startTime','string'), > SQLField('endTime','string'), > SQLField('room','string')) > > #A speaker can give many sessions (talk,song,speech, > etc...) > db.define_table('speaker', > SQLField('name','string'), > SQLField('session','string'), > SQLField('subject','string'), > SQLField('description','text'), > SQLField('logo','upload')) > > #A user can attend many sessions > db.define_table('attendance', > SQLField('nickname','string'), > SQLField('session','string')) > --- > Hope you can help. :) > Regards, > Jason Brower --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---