Esempio n. 1
0
 def POST(self, arg):
     try:
         if user.username == arg:
             email = web.input().regEmail
             #发送验证邮件
             token = md5.md5(time.ctime() + email).hexdigest()
             #判断邮箱激活表中是否有此email或者douban_id
             if not users.user_exist_in_table_confirm_email(
                     email, user.douban_id):
                 try:
                     email_templates.msg_new_user_email(user, email, token)
                     #保存记录到数据库
                     users.save_confirm_email(email, user.douban_id, token)
                     #跳转到邮件发送成功页面
                     return web.seeother(
                         '/welcome/' + user.username +
                         '/send_email_feedback?status=succesful')
                 except Exception, e:
                     print 'error--------'
                     print e
                     return web.seeother(
                         '/welcome/' + user.username +
                         '/send_email_feedback?status=failed')
             else:
                 #数据库中已经有记录了
                 return web.seeother(
                     '/welcome/' + user.username +
                     '/send_email_feedback?status=duplicate')
         else:
Esempio n. 2
0
 def POST(self):
     f = web.input(regNickname="", regUserName="", regEmail="", regUserPassword="", regUserPassword2="")
     users.create_account(f.regUserName, f.regEmail, f.regUserPassword, f.regNickname) #用户表入库
     token = md5.md5(time.ctime() + f.regEmail).hexdigest()
     email_templates.create_account(f.regEmail, token)
     users.save_confirm_email(f.regEmail, token)
     session.login(f.regEmail)
     raise web.seeother('/')
Esempio n. 3
0
    def POST(self):
        f = self.form()
        if not f.validates(web.input(_unicode=False)):
            show = web.input(show='all').show
            return render_account(show, register_form=f)
        elif len(f.d.username) > 16 :
            return render_account(
                show = 'register_only',
                error_message = '<span class="alert alert-error">不能超过16位</span>',
                register_form=f
            )
        elif len(f.d.username) < 2 :
            return render_account(
                show = 'register_only',
                error_message = '<span class="alert alert-error">不能少过2位</span>',
                register_form=f
            )
        elif not (re.search('^[a-zA-Z]{1}[\w\-]{5,15}$', f.d.username)):
            return render_account(
                show = 'register_only',
                error_message = '<span class="alert alert-error">请以字母开头,6-16个字母、数字</span>',
                register_form=f
            )
        else:
            users.create_account(f.d.username, f.d.email, f.d.password, f.d.nickname, '/static/public/img/default_48x48.jpg')
            id = users.get_user_by_email(f.d.email).id
            users.update_user_by_id(
                id,
                douban_id=id
            )

            if not users.is_user_exist_in__permission(id):
                db.insert('_permission', douban_id = id, rights = 1)
            if users.is_user_profile_exist(id):
                users.update_profile(id, city = '上海', bio = '')
            else:
                users.insert_profile(id, city = '上海', bio = '')

            session.login(f.d.email)
            user.is_logged = False # 虽然注册了, 但是还要等邮件确认
            user.douban_id = id

            token = md5.md5(time.ctime() + f.d.email).hexdigest()
            try:
                email_templates.msg_new_user_email(user, f.d.email, token)
                #保存记录到数据库
                users.save_confirm_email(f.d.email, user.id, token)
                #跳转到邮件发送成功页面
                return web.seeother('/welcome/'+ f.d.username +'/send_email_feedback?status=succesful')
            except Exception, e:
                print 'error--------, send email feedback ------------------'
                print e
                return web.seeother('/welcome/'+ f.d.username +'/send_email_feedback?status=failed')
Esempio n. 4
0
 def POST(self):
     f = web.input(regNickname="",
                   regUserName="",
                   regEmail="",
                   regUserPassword="",
                   regUserPassword2="")
     users.create_account(f.regUserName, f.regEmail, f.regUserPassword,
                          f.regNickname)  #用户表入库
     token = md5.md5(time.ctime() + f.regEmail).hexdigest()
     email_templates.create_account(f.regEmail, token)
     users.save_confirm_email(f.regEmail, token)
     session.login(f.regEmail)
     raise web.seeother('/')
Esempio n. 5
0
 def POST(self, arg):
     if user.username == arg:
         email = web.input().regEmail
         #发送验证邮件
         token = md5.md5(time.ctime() + email).hexdigest()
         #判断邮箱激活表中是否有此email或者douban_id
         if not users.user_exist_in_table_confirm_email(email, user.douban_id):
             try:
                 email_templates.msg_new_user_email(user, email, token)
                 #保存记录到数据库
                 users.save_confirm_email(email, user.douban_id, token)
                 #跳转到邮件发送成功页面
                 return web.seeother('/welcome/'+ user.username +'/send_email_feedback?status=succesful')
             except Exception, e:
                 print 'error--------, send email feedback ------------------'
                 print e
                 return web.seeother('/welcome/'+ user.username +'/send_email_feedback?status=failed')
         else:
             #数据库中已经有记录了
             return web.seeother('/welcome/'+ user.username +'/send_email_feedback?status=duplicate')