コード例 #1
0
ファイル: views.py プロジェクト: weizai118/LuoYunCloud
    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()
コード例 #2
0
ファイル: views.py プロジェクト: cloudcache/LuoYunCloud
    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()
コード例 #3
0
ファイル: user_views.py プロジェクト: cloudcache/LuoYunCloud
    def post(self):

        form = CreateUserForm(self)

        if form.validate():

            user = self.db.query(User).filter_by(
                username=form.username.data ).first()

            if user:
                form.username.errors.append(
                    _('This username is occupied') )
            else:
                enc_password = enc_login_passwd(form.password.data)

                new = User( username = form.username.data,
                            password = enc_password )
                self.db.add( new )
                self.db.commit()

                new.init_account(self.db)

                profile = UserProfile( new )
                self.db.add(profile)
                self.db.commit()

                url = self.reverse_url('admin:user:view')
                url += '?id=%s' % new.id
                return self.redirect( url )

        self.render( form = form )
コード例 #4
0
    def post(self):

        form = CreateUserForm(self)

        if form.validate():

            user = self.db.query(User).filter_by(
                username=form.username.data).first()

            if user:
                form.username.errors.append(_('This username is occupied'))
            else:
                enc_password = enc_login_passwd(form.password.data)

                new = User(username=form.username.data, password=enc_password)
                self.db.add(new)
                self.db.commit()

                new.init_account(self.db)

                profile = UserProfile(new)
                self.db.add(profile)
                self.db.commit()

                url = self.reverse_url('admin:user:view')
                url += '?id=%s' % new.id
                return self.redirect(url)

        self.render(form=form)
コード例 #5
0
ファイル: views.py プロジェクト: weizai118/LuoYunCloud
    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')
コード例 #6
0
ファイル: views.py プロジェクト: cloudcache/LuoYunCloud
    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')