예제 #1
0
	def get(self):

		refresh_token = request.headers.get("REFRESH_TOKEN").split(" ")[-1]
		maneger = ManageUser()
		strategy = RefreshTokenAdminStrategy()
		tokens = maneger.refresh(strategy, refresh_token)

		return Utils.response_auth(tokens["token_id"], tokens["refresh_token"])
예제 #2
0
	def post(self):

		manage = ManageUser()
		strategy = LoginUserStrategy()
		try:
			tokens = manage.login(strategy, request.json)

		except InvalidParametersError as e:
			return Utils.response(status=e.status, data=e.errors, message="Invalid parameters")
		
		except AuthenticationError as e:
			return Utils.response(status=e.status, data=e.errors, message="Invalid credentials")

		return Utils.response_auth(tokens["token_id"], tokens["refresh_token"])