Fixed automated code review warnings
This commit is contained in:
@@ -14,7 +14,7 @@ async function login(request: UnwrappedRequest): Promise<Response> {
|
||||
refreshCount: string;
|
||||
} | null = await orm.users.verifyCredentials(requestBody.username, requestBody.password);
|
||||
if (!verify) {
|
||||
throw new UnauthorizedError('Invalid credentials');
|
||||
return new UnauthorizedResponse('Invalid credentials');
|
||||
}
|
||||
|
||||
// Build refresh token that expires in 30 days, return as secure HTTP only cookie.
|
||||
@@ -46,7 +46,7 @@ async function token(request: UnwrappedRequest): Promise<Response> {
|
||||
const cookies = request.request.cookies;
|
||||
const refreshCookie = cookies.get('refresh');
|
||||
if (!refreshCookie) {
|
||||
throw new UnauthorizedError('No refresh token found');
|
||||
return new UnauthorizedResponse('No refresh token found');
|
||||
}
|
||||
|
||||
const refreshToken: {
|
||||
@@ -69,7 +69,7 @@ async function token(request: UnwrappedRequest): Promise<Response> {
|
||||
}
|
||||
}
|
||||
|
||||
async function logout(request: UnwrappedRequest): Promise<Response> {
|
||||
async function logout(): Promise<Response> {
|
||||
try {
|
||||
const response = new OkResponse();
|
||||
response.headers.set('Clear-Site-Data', '"cookies","cache","storage","executionContexts"');
|
||||
@@ -79,14 +79,13 @@ async function logout(request: UnwrappedRequest): Promise<Response> {
|
||||
}
|
||||
}
|
||||
|
||||
async function changePassword(request: UnwrappedRequest): Promise<Response> {
|
||||
async function changePassword(request: UnwrappedRequest<ChangePasswordRequest>): Promise<Response> {
|
||||
try {
|
||||
const requestBody = request.body as ChangePasswordRequest;
|
||||
return new OkResponse(
|
||||
await orm.users.changePassword(
|
||||
SecureId.fromHash(request.params.id),
|
||||
requestBody.oldPassword,
|
||||
requestBody.newPassword,
|
||||
request.body.oldPassword,
|
||||
request.body.newPassword,
|
||||
request.claims,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user