Beispiel #1
0
 def authenticateUser(self, authGuid):
     # kill existing session
     # self.session.kill()
     
     userId, redirectLink = mUser.createUserFromAuthGuid(self.db, authGuid)
     isSuccess = False
     
     if (userId):
         isSuccess = True
         user = mUser.User(self.db, userId)
     
         # log in user
         self.session.user_id = userId
         self.session.invalidate()
         # set cbu_key for blog access
         web.setcookie('cbu_key', util.obfuscate(userId), domain = ".changeby.us")
         
         mIdea.attachIdeasByEmail(self.db, user.email)
         
         if (user.phone and len(user.phone) > 0):
             mIdea.attachIdeasByPhone(self.db, user.phone)            
 
     return self.render('join', { 'is_email_auth_attempt':True, 
                                  'is_email_auth_attempt_successful': isSuccess,
                                  'post_auth_redirect_link': redirectLink })
Beispiel #2
0
    def authenticateUser(self, authGuid):
        # kill existing session
        # self.session.kill()

        userId = mUser.createUserFromAuthGuid(self.db, authGuid)
        isSuccess = False

        if (userId):
            isSuccess = True
            user = mUser.User(self.db, userId)

            # log in user
            self.session.user_id = userId
            self.session.invalidate()
            # set cbu_key for blog access
            web.setcookie('cbu_key',
                          util.obfuscate(userId),
                          domain=".changeby.us")

            mIdea.attachIdeasByEmail(self.db, user.email)

            if (user.phone and len(user.phone) > 0):
                mIdea.attachIdeasByPhone(self.db, user.phone)

        return self.render(
            'join', {
                'is_email_auth_attempt': True,
                'is_email_auth_attempt_successful': isSuccess
            })
Beispiel #3
0
    def newUser(self):
        firstName = self.request('f_name')
        lastName = self.request('l_name')
        email = self.request('email')
        password = self.request('password')
        phone = util.cleanUSPhone(self.request('sms_phone'))
        code = self.request('beta_code')

        if (self.appMode == 'beta' and not self.verifyBetaCode(code)):
            log.error("*** beta user attempted register w/ invalid code")
            return False
        elif (len(firstName) == 0):
            log.error("*** error on user create: no first name")
            return False
        elif (len(lastName) == 0):
            log.error("*** error on user create: no last name")
            return False
        elif (len(email) == 0 or not util.validate_email(email)):
            log.error("*** error on user create: invalid email")
            return False
        elif (len(password) == 0):
            log.error("*** error on user create: no password")
            return False
        else:
            userId = mUser.createUser(self.db, email, password, firstName,
                                      lastName, phone)

            if (userId):
                # log in user
                self.session.user_id = userId
                self.session.invalidate()
                # set cbu_key for blog access
                web.setcookie('cbu_key',
                              util.obfuscate(userId),
                              domain=".changeby.us")

                if (self.appMode == 'beta'):
                    self.expireBetaCode(code, userId)

                mIdea.attachIdeasByEmail(self.db, email)

                if (phone and len(phone) > 0):
                    mIdea.attachIdeasByPhone(self.db, phone)

                return userId
            else:
                return False
Beispiel #4
0
    def newUser(self):
        firstName = self.request('f_name')
        lastName = self.request('l_name')
        email = self.request('email')
        password = self.request('password')
        phone = util.cleanUSPhone(self.request('sms_phone'))
        code = self.request('beta_code')        
                
        if (self.appMode == 'beta' and not self.verifyBetaCode(code)):
            log.error("*** beta user attempted register w/ invalid code")
            return False        
        elif (len(firstName) == 0): 
            log.error("*** error on user create: no first name")
            return False
        elif (len(lastName) == 0): 
            log.error("*** error on user create: no last name")
            return False
        elif (len(email) == 0 or not util.validate_email(email)): 
            log.error("*** error on user create: invalid email")
            return False
        elif (len(password) == 0): 
            log.error("*** error on user create: no password")
            return False
        else:
            userId = mUser.createUser(self.db, email, password, firstName, lastName, phone)
            
            if (userId):
                # log in user
                self.session.user_id = userId
                self.session.invalidate()
                # set cbu_key for blog access
                web.setcookie('cbu_key', util.obfuscate(userId), domain = ".changeby.us")

            
                if (self.appMode == 'beta'):
                    self.expireBetaCode(code, userId)
                
                mIdea.attachIdeasByEmail(self.db, email)
                
                if (phone and len(phone) > 0):
                    mIdea.attachIdeasByPhone(self.db, phone)
            
                return userId
            else:
                return False
Beispiel #5
0
    def login(self):
        email = self.request("email")
        password = self.request("password")

        if (email and password):
            #userId = mUser.authenticateUser(self.db, email, password)
            user = mUser.authGetUser(self.db, email, password)

            if (user):
                self.session.user_id = user['u_id']
                self.session.invalidate()
                # set cbu_key for blog access
                web.setcookie('cbu_key', util.obfuscate(user['u_id']), domain = ".changeby.us")

                return self.json(user)
            else:
                return False
        else:
            log.error("*** Login attempt missing email or password")
            return False
Beispiel #6
0
    def login(self):
        email = self.request("email")
        password = self.request("password")

        if (email and password):
            #userId = mUser.authenticateUser(self.db, email, password)
            user = mUser.authGetUser(self.db, email, password)

            if (user):
                self.session.user_id = user['u_id']
                self.session.invalidate()
                # set cbu_key for blog access
                web.setcookie('cbu_key',
                              util.obfuscate(user['u_id']),
                              domain=".changeby.us")

                return self.json(user)
            else:
                return False
        else:
            log.error("*** Login attempt missing email or password")
            return False
Beispiel #7
0
 def test_obfuscate(self):
     self.assertEqual(util.obfuscate(100), "MTAwd3h5ekFCQ0RF")