Skip to content

Commit

Permalink
feat: simplify file menu, case insensitive username for IdP
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Jun 29, 2024
1 parent 8c5230c commit 24a8c56
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 165 deletions.
6 changes: 3 additions & 3 deletions idp/src/account/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { hashPassword } from '@/infra/password'
import search, { USER_SEARCH_INDEX } from '@/infra/search'
import { User } from '@/user/model'
import userRepo from '@/user/repo'
import { mapEntity, UserDTO } from '@/user/service'
import { UserDTO, mapEntity } from '@/user/service'

export type AccountCreateOptions = {
email: string
Expand Down Expand Up @@ -40,8 +40,8 @@ export async function createUser(
const emailConfirmationToken = newHyphenlessUuid()
const user = await userRepo.insert({
id,
username: options.email,
email: options.email,
username: options.email.toLocaleLowerCase(),
email: options.email.toLocaleLowerCase(),
fullName: options.fullName,
picture: options.picture,
passwordHash: hashPassword(options.password),
Expand Down
2 changes: 1 addition & 1 deletion idp/src/token/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function exchange(options: TokenExchangeOptions): Promise<Token> {
if (options.grant_type === 'password') {
let user: User
try {
user = await userRepo.findByUsername(options.username)
user = await userRepo.findByUsername(options.username.toLocaleLowerCase())
} catch {
throw newError({ code: ErrorCode.InvalidUsernameOrPassword })
}
Expand Down
Loading

0 comments on commit 24a8c56

Please sign in to comment.