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))
Exemple #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))
Exemple #3
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))
    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.USER_ID] = params[KEY.USER_ID]
            resp[KEY.PASSWORD] = params[KEY.PASSWORD]
            rest[KEY.GENDER] = params[KEY.GENDER]
            resp[KEY.PHONE] = params[KEY.PHONE]
            resp[KEY.JOB] = params[KEY.JOB]
            resp[KEY.AGE] = params[KEY.AGE]
        else:
            resp[KEY.STATUS] = STATUS.ERROR

        return self.write(json_encode(resp))