コード例 #1
0
    def done(self):
        #make sure the user doesn't already exist
        u = User.by_name(self.username)
        if u:
            msg = 'That user already exists.'
            self.render('signup-form.html', error_username=msg)
        else:
            u = User.register(self.username, self.password, self.email)
            u.put()

            self.login(u)
            self.redirect('/')
コード例 #2
0
    def done(self):
        #make sure the user doesn't already exist
        u = User.by_name(self.username)
        if u:
            msg = 'That user already exists.'
            self.render('signup-form.html', error_username = msg)
        else:
            u = User.register(self.username, self.password, self.email)
            u.put()

            self.login(u)
            self.redirect('/')
コード例 #3
0
    def initialize(self, *a, **kw):
        webapp2.RequestHandler.initialize(self, *a, **kw)
        uid = self.read_secure_cookie('user_id')
        self.user = uid and User.by_id(int(uid))

        if self.request.url.endswith('.json'):
            self.format = 'json'
        else:
            self.format = 'html'
コード例 #4
0
    def initialize(self, *a, **kw):
        webapp2.RequestHandler.initialize(self, *a, **kw)
        uid = self.read_secure_cookie('user_id')
        self.user = uid and User.by_id(int(uid))

        if self.request.url.endswith('.json'):
            self.format = 'json'
        else:
            self.format = 'html'
コード例 #5
0
ファイル: main.py プロジェクト: thangle2008/my-web-games
    def post(self):
        have_error = False

        next_url = str(self.request.get('next_url'))
        if not next_url or next_url.startswith('/login'):
            next_url = '/'

        self.username = self.request.get('username')
        self.password = self.request.get('password')
        self.verify = self.request.get('verify')
        self.email = self.request.get('email')

        params = dict(username = self.username,
                      email = self.email)

        if not valid_username(self.username):
            params['error_username'] = "******"
            have_error = True

        if not valid_password(self.password):
            params['error_password'] = "******"
            have_error = True
        elif self.password != self.verify:
            params['error_verify'] = "Your passwords didn't match."
            have_error = True

        if not valid_email(self.email):
            params['error_email'] = "That's not a valid email."
            have_error = True

        if have_error:
            self.render('signup-form.html', **params)
        else:
            u = User.by_name(self.username)
            if u:
                msg = 'That user already exists.'
                self.render('signup-form.html', error_username = msg)
            else:
                u = User.register(self.username, self.password, self.email)
                u.put()

                self.login(u)
                self.redirect(next_url)
コード例 #6
0
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')

        u = User.login(username, password)
        if u:
            self.login(u)
            self.redirect('/')
        else:
            msg = 'Invalid login'
            self.render('login-form.html', error = msg)
コード例 #7
0
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')

        u = User.login(username, password)
        if u:
            self.login(u)
            self.redirect('/')
        else:
            msg = 'Invalid login'
            self.render('login-form.html', error=msg)
コード例 #8
0
def save_user_info():
    user_info = get_user_info()
    user_id = user_info.get('id')
    user = User()
    existing_user = User.collection.get(f'users/{user_id}')
    if existing_user is None:
        user.id = user_info.get('id', None)
        user.email = user_info.get('email', None)
        user.name = user_info.get('name', None)
        user.profile_pic = user_info.get('picture', None)
        user.last_login = datetime.today()
        user.save()
        flask.session['user_email'] = user.email
    else:
        existing_user.last_login = datetime.today()
        existing_user.update()
        # update and store user's detail in session
        flask.session['user_email'] = existing_user.email
        record = GhostRecord.get_email_record(existing_user.email)
        flask.session['ghost_name'] = [r.name for r in record if r.name]
コード例 #9
0
ファイル: main.py プロジェクト: thangle2008/my-web-games
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')

        next_url = str(self.request.get('next_url'))
        if not next_url or next_url.startswith('/login'):
            next_url = '/'

        u = User.login(username, password)
        if u:
            self.login(u)
            self.redirect(next_url)
        else:
            msg = 'Invalid login'
            self.render('login-form.html', error = msg)
コード例 #10
0
ファイル: main.py プロジェクト: thangle2008/my-web-games
 def initialize(self, *a, **kw):
     webapp2.RequestHandler.initialize(self, *a, **kw)
     uid = self.read_secure_cookie('user_id')
     self.user = uid and User.by_id(int(uid))
コード例 #11
0
 def initialize(self, *a, **kw):
     """Initialize."""
     webapp2.RequestHandler.initialize(self, *a, **kw)
     uid = self.read_secure_cookie('user_id')
     self.user = uid and User.by_id(int(uid))