Esempio n. 1
0
    def post(self):

        form = self.form
        openid = self.openid

        if form.validate():

            encpass = enc_login_passwd(form.password.data)
            U = User(username=form.username.data,
                     password=encpass,
                     language=self.language)

            user_info = self.get_user_info
            U.nickname = user_info.get('nickname', U.username)

            U.email = form.email.data

            self.db.add(U)
            self.db.commit()

            U.init_account(self.db)
            U.last_login = datetime.datetime.now()
            openid.user_id = U.id
            self.db.commit()

            self.save_session(U.id)
            self.db.delete(self.K)
            self.db.commit()

            return self.redirect_next('/account')

        self.render()
Esempio n. 2
0
    def post(self):

        form = self.form
        openid = self.openid

        if form.validate():

            encpass = enc_login_passwd(form.password.data)
            U = User( username = form.username.data,
                      password = encpass,
                      language = self.language )

            user_info = self.get_user_info
            U.nickname = user_info.get('nickname', U.username)

            U.email = form.email.data

            self.db.add( U )
            self.db.commit()

            U.init_account(self.db)
            U.last_login = datetime.datetime.now()
            openid.user_id = U.id
            self.db.commit()

            self.save_session(U.id)
            self.db.delete(self.K)
            self.db.commit()

            return self.redirect_next('/account')

        self.render()
Esempio n. 3
0
    def _on_user_info2(self, data):

        data = json.loads(data)

        ret = data.get('ret', None)
        if ret != 0:
            self.write(_('QQ auth failed: %s') % data.get('msg', ''))
            return self.finish()

        # create new user
        O = OpenID(openid=self.openid, _type=1)  # TODO: QQ now
        O.config = json.dumps({'get_user_info': data})
        self.db.add(O)
        self.db.commit()

        while True:
            username = '******' % random.randint(1, 10000000)
            U = self.db.query(User).filter_by(username=username).first()
            if not U: break

        U = User(username=username,
                 password='******',
                 language=self.language)

        U.nickname = data.get('nickname', None)
        U.email_valid = True
        self.db.add(U)
        self.db.commit()

        U.init_account(self.db)

        self.save_session(U.id)
        U.last_login = datetime.datetime.now()

        O.user_id = U.id

        self.db.commit()

        # TODO: drop account relationships
        profile = UserProfile(U)
        self.db.add(profile)
        self.db.commit()

        self.redirect('/account')
Esempio n. 4
0
    def _on_user_info2(self, data):

        data = json.loads( data )

        ret = data.get('ret', None)
        if ret != 0:
            self.write(_('QQ auth failed: %s') % data.get('msg',''))
            return self.finish()

        # create new user
        O = OpenID( openid = self.openid, _type = 1 ) # TODO: QQ now
        O.config = json.dumps( { 'get_user_info': data } )
        self.db.add(O)
        self.db.commit()

        while True:
            username = '******' % random.randint(1, 10000000)
            U = self.db.query(User).filter_by(username=username).first()
            if not U: break
            
        U = User( username = username,
                  password = '******',
                  language = self.language )

        U.nickname = data.get('nickname', None)
        U.email_valid = True
        self.db.add( U )
        self.db.commit()

        U.init_account(self.db)

        self.save_session(U.id)
        U.last_login = datetime.datetime.now()

        O.user_id = U.id

        self.db.commit()

        # TODO: drop account relationships
        profile = UserProfile( U )
        self.db.add(profile)
        self.db.commit()

        self.redirect('/account')