def submit(self): user = User.fromMap(self.cleaned_data) # check if username and email have not been used yet # if they have not then save the user if User.getByEmail(user.email) or User.getByUsername(user.username): raise UserConflictException() user.save() return UserSerializer(user).data
def submit(self): user = User.getByUsername(self.cleaned_data['username']) if not user: raise SessionAuthorizationException() if not user.authenticate(self.cleaned_data['password']): raise SessionAuthorizationException() self.cleaned_data['user_id'] = UUID(user.user_id) del self.cleaned_data['username'] del self.cleaned_data['password'] session = Session.fromMap(self.cleaned_data) session.save() return SessionSerializer(session).data
def submit(self): if 'username' in self.cleaned_data: ans = User.getByUsername(self.cleaned_data['username']) uResponse = UserSerializer([] if not ans else [ans], many=True).data response = { 'data' : uResponse } return response elif 'email' in self.cleaned_data: ans = User.getByEmail(self.cleaned_data['email']) uResponse = UserSerializer([] if not ans else [ans], many=True).data response = { 'data' : uResponse } return response else: ans = User.all(page=self.cleaned_data['page'], limit=self.cleaned_data['limit']) uResponse = UserSerializer(ans, many=True).data response = { 'data' : uResponse } if ans: response['next'] = ans[-1].user_id return response