def post(self): user_name = self.request.get('login_name') password = base.hash_str(self.request.get('login_pass')) output_json = {} u = user.User.by_name(user_name) if u: if self.validate_password(u, password): self.login(u) self.redirect('/resume') else: output_json['status'] = 'ERR' output_json['password_error'] = 'Incorrect Password!' else: u = user.User.by_email(user_name) if u: if self.validate_password(u, password): self.login(u) output_json['status'] = 'OK' else: output_json['status'] = 'ERR' output_json['password_error'] = 'Incorrect password!' else: output_json['status'] = 'ERR' output_json['name_error'] = 'Invalid username!' self.render_json(json.dumps(output_json))
def post(self): has_error = False user_name = self.request.get('user_name') first_name = self.request.get('first_name') last_name = self.request.get('last_name') email = self.request.get('email') email_confirm = self.request.get('email_confirm') password = base.hash_str(self.request.get('password')) output_json = {} # check validity of user name valid_name = self.is_valid_name(user_name) if not valid_name[0]: has_error = True output_json['user_name_error'] = valid_name[1] # check validity of email valid_email = self.is_valid_email(email) if not valid_email[0]: has_error = True output_json['email_error'] = valid_email[1] elif email != email_confirm: has_error = True output_json['email_error'] = 'Emails did not match.' if has_error: output_json['status'] = 'ERR' else: u = user.User.create_user(first_name=first_name, last_name=last_name, user_name=user_name, email=email, password=password) coord = None # base.get_user_location(self.request.remote_addr) if coord: u.location = coord u.put() self.login(u) self.send_confirmation_email(u) output_json['status'] = 'OK' self.render_json(json.dumps(output_json))