Пример #1
0
    def post(self):
        params = {}
        resp = {}
        params = utils.decode_params(self.request)

        if KEY.ACCOUNT in params and KEY.PASSWORD in params and KEY.PHONE in params:
            if Session.Session.exists(params):
                '''if user not exists, return true'''
                if db.check_user_exist(params):
                    user_id = db.add_account(params)
                    if user_id > 0:
                        '''set the user phone number'''
                        db.update_user({
                            KEY.ID: user_id,
                            KEY.PHONE: params[KEY.PHONE]
                        })
                        resp[KEY.STATUS] = 200
                        resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
                        resp[KEY.ID] = user_id
                        resp[KEY.SALT] = db.get_salt(params)
                        resp[KEY.CHAT_TOKEN] = db.get_chat_token(params)
                        bank_account_id = db.create_loving_bank(resp, 20, 0)

                    else:
                        resp[KEY.STATUS] = 250
                else:
                    resp[KEY.STATUS] = 260
            else:
                resp[KEY.STATUS] = 270
        else:
            resp[KEY.STATUS] = 300

        self.write(json_encode(resp))
Пример #2
0
    def post(self):
        params = {}
        resp = {}
        params = utils.decode_params(self.request)
        
        if KEY.ACCOUNT in params and KEY.PASSWORD in params and KEY.PHONE in params:
            if Session.Session.exists(params):
                '''if user not exists, return true'''
                if db.check_user_exist(params):
                    user_id = db.add_account(params)
                    if user_id > 0:
                        '''set the user phone number'''
                        db.update_user({KEY.ID: user_id, KEY.PHONE: params[KEY.PHONE]})
                        resp[KEY.STATUS] = 200
                        resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
                        resp[KEY.ID] = user_id
                        resp[KEY.SALT] = db.get_salt(params)
                        resp[KEY.CHAT_TOKEN] = db.get_chat_token(params)
                        bank_account_id = db.create_loving_bank(resp, 20, 0)
                        
                    else:
                        resp[KEY.STATUS] = 250
                else:
                    resp[KEY.STATUS] = 260
            else:
                resp[KEY.STATUS] = 270
        else:
            resp[KEY.STATUS] = 300

        self.write(json_encode(resp))
Пример #3
0
    def post(self):
        params = utils.decode_params(self.request)
        resp = {}
        if KEY.SALT not in params:
            salt = db.get_salt(params)
            if salt is None:
                resp[KEY.STATUS] = STATUS.ERROR
            else:
                resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
                resp[KEY.STATUS] = STATUS.OK
                resp[KEY.SALT] = salt

        else:
            user_id = db.validate_password(params)
            print user_id
            if user_id > 0:
                resp[KEY.STATUS] = STATUS.OK
                resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
                resp[KEY.ID] = user_id
                if not utils.is_App(self.request):
                    self.set_secure_cookie("username", resp[KEY.ACCOUNT])
                    self.set_secure_cookie("id", str(resp[KEY.ID]))
            else:
                resp[KEY.STATUS] = STATUS.ERROR

        self.write(json_encode(resp))
Пример #4
0
    def post(self):
        params = utils.decode_params(self.request)
        resp = {}
        if KEY.SALT not in params:
            salt = db.get_salt(params)
            if salt is None:
                resp[KEY.STATUS] = 500
            else:
                resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
                resp[KEY.SALT] = salt
                user_id = db.validate_password(params)
                if user_id > 0:
                    resp[KEY.STATUS] = 200
                    resp[KEY.ID] = user_id
                    self.set_secure_cookie(KEY.USER_NAME, resp[KEY.ACCOUNT])
                    self.set_secure_cookie(KEY.ID, str(resp[KEY.ID]))
                else:
                    resp[KEY.STATUS] = 300

        else:
            user_id = db.validate_password(params)
            if user_id > 0:
                resp[KEY.STATUS] = 200
                resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
                resp[KEY.ID] = user_id
                self.set_secure_cookie(KEY.USER_NAME, resp[KEY.ACCOUNT])
                self.set_secure_cookie(KEY.ID, str(resp[KEY.ID]))
            else:
                resp[KEY.STATUS] = 300

        self.write(json_encode(resp))
Пример #5
0
  def post(self):
    params = utils.decode_params(self.request)
    resp = {}
    if KEY.SALT not in params:
      salt = db.get_salt(params)
      if salt is None:
        resp[KEY.STATUS] = 500
      else:
        resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
        resp[KEY.SALT] = salt
        user_id = db.validate_password(params)
        if user_id > 0:
          resp[KEY.STATUS] = 200
          resp[KEY.ID] = user_id
          self.set_secure_cookie(KEY.USER_NAME, resp[KEY.ACCOUNT])
          self.set_secure_cookie(KEY.ID, str(resp[KEY.ID]))
        else:
          resp[KEY.STATUS] = 300
    
    else:
      user_id = db.validate_password(params)
      if user_id > 0:
        resp[KEY.STATUS] = 200
        resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
        resp[KEY.ID] = user_id
        self.set_secure_cookie(KEY.USER_NAME, resp[KEY.ACCOUNT])
        self.set_secure_cookie(KEY.ID, str(resp[KEY.ID]))
      else:
        resp[KEY.STATUS] = 300

    self.write(json_encode(resp))
Пример #6
0
  def post(self):
    params = utils.decode_params(self.request)
    resp = {}
    if KEY.SALT not in params:
      salt = db.get_salt(params)
      if salt is None:
        resp[KEY.STATUS] = STATUS.ERROR
      else:
        resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
        resp[KEY.STATUS] = STATUS.OK
        resp[KEY.SALT] = salt

    else:
      user_id = db.validate_password(params)
      print user_id
      if user_id > 0:
        resp[KEY.STATUS] = STATUS.OK
        resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
        resp[KEY.ID] = user_id
        if not utils.is_App(self.request):
          self.set_secure_cookie("username", resp[KEY.ACCOUNT])
          self.set_secure_cookie("id", str(resp[KEY.ID]))
      else:
        resp[KEY.STATUS] = STATUS.ERROR
      
    self.write(json_encode(resp))
Пример #7
0
  def post(self):
    params = utils.decode_params(self.request)
    print "From login handler: "
    print params
    resp = {}
    if KEY.SALT not in params:
      salt = db.get_salt(params)
      if salt is None:
        resp[KEY.STATUS] = STATUS.ERROR
      else:
        resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
        resp[KEY.SALT] = salt
        #resp[KEY.STATUS] = STATUS.OK
    
    else:
      user_id = db.validate_password(params)
      if user_id > 0:
        resp[KEY.STATUS] = STATUS.OK
        resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
        resp[KEY.ID] = user_id
      else:
        resp[KEY.STATUS] = STATUS.ERROR

    print "From login handler: resp:"
    print resp
    self.write(json_encode(resp))
Пример #8
0
 def post(self):
   params = utils.decode_params(self.request)
   user_id = db.add_account(params)
   resp = {}
   if user_id > 0:
     resp[KEY.STATUS] = STATUS.OK
     resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
     resp[KEY.ID] = user_id
     resp[KEY.SALT] = db.get_salt(params)
     bank_account_id = db.create_loving_bank(resp, 20, 0)
   else:
     resp[KEY.STATUS] = STATUS.ERROR
   
   self.write(json_encode(resp))
Пример #9
0
	def post(self):
		params = {}
		resp = {}
		resp[KEY.STATUS] = STATUS.ERROR
		params = utils.decode_params(self.request)
		salt = db.get_salt(params)
		if salt:
			md5_encode = hashlib.md5()

			md5_encode.update(params[KEY.PASSWORD] + salt)
			params[KEY.PASSWORD] = md5_encode.hexdigest()
			isModfied = db.modify_password_For_Forget(params)
			if isModfied:
				resp[KEY.STATUS] = STATUS.OK

		self.write(json_encode(resp))
Пример #10
0
    def post(self):

        params = {}
        params = utils.decode_params(self.request)
        salt = ""

        if KEY.ACCOUNT in params:

            salt = db.get_salt(params)
        elif KEY.ID in params:

            params[KEY.ID] = int(params[KEY.ID])

            salt = db.get_salt_by_id(params)

        if salt is None:
            salt = ""
        self.write(salt)
Пример #11
0
    def post(self):


        params = {}
        params = utils.decode_params(self.request)
        salt = ""

        if KEY.ACCOUNT in params:

            salt = db.get_salt(params)
        elif KEY.ID in params:

            params[KEY.ID] = int(params[KEY.ID])

            salt = db.get_salt_by_id(params)

        if salt is None:
            salt = ""
        self.write(salt)
Пример #12
0
 def post(self):
   params = utils.decode_params(self.request)
   
   resp = {}
   if KEY.SALT not in params:
     salt = db.get_salt(params)
     if salt is None:
       resp[KEY.STATUS] = STATUS.ERROR
     else:
       resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
       resp[KEY.SALT] = salt
   
   else:
     user_id = db.validate_password(params)
     if user_id > 0:
       resp[KEY.STATUS] = STATUS.OK
       resp[KEY.ACCOUNT] = params[KEY.ACCOUNT]
       resp[KEY.ID] = user_id
     else:
       resp[KEY.STATUS] = STATUS.ERROR
   
   self.write(json_encode(resp))