Update authUser mutation to accept optional workplaceNumber parameter and adjust login function accordingly. Enhance API logging for authentication requests to include workplaceNumber for better debugging.
Some checks failed
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
Some checks failed
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -33,7 +33,7 @@ export const api = createApi({
|
|||||||
}),
|
}),
|
||||||
tagTypes: ['Chains', 'Chain', 'UserStats', 'SystemStats', 'Submissions', 'Queue'],
|
tagTypes: ['Chains', 'Chain', 'UserStats', 'SystemStats', 'Submissions', 'Queue'],
|
||||||
endpoints: (builder) => ({
|
endpoints: (builder) => ({
|
||||||
authUser: builder.mutation<ChallengeAuthResponse, { nickname: string }>({
|
authUser: builder.mutation<ChallengeAuthResponse, { nickname: string; workplaceNumber?: string }>({
|
||||||
query: (body) => ({
|
query: (body) => ({
|
||||||
url: '/auth',
|
url: '/auth',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -160,7 +160,10 @@ export const ChallengeProvider = ({ children }: PropsWithChildren) => {
|
|||||||
|
|
||||||
const login = useCallback(
|
const login = useCallback(
|
||||||
async (nicknameValue: string, workplaceNumberValue: string) => {
|
async (nicknameValue: string, workplaceNumberValue: string) => {
|
||||||
const response = await authUser({ nickname: nicknameValue }).unwrap()
|
const response = await authUser({
|
||||||
|
nickname: nicknameValue,
|
||||||
|
workplaceNumber: workplaceNumberValue || undefined
|
||||||
|
}).unwrap()
|
||||||
setUserId(response.userId)
|
setUserId(response.userId)
|
||||||
setNickname(nicknameValue)
|
setNickname(nicknameValue)
|
||||||
setWorkplaceNumber(workplaceNumberValue)
|
setWorkplaceNumber(workplaceNumberValue)
|
||||||
|
|||||||
@@ -24,7 +24,13 @@ router.use((req, res, next) => {
|
|||||||
|
|
||||||
// Challenge API endpoints
|
// Challenge API endpoints
|
||||||
router.post('/challenge/auth', (req, res) => {
|
router.post('/challenge/auth', (req, res) => {
|
||||||
res.json(readJson('auth.json'))
|
const { nickname, workplaceNumber } = req.body
|
||||||
|
const response = readJson('auth.json')
|
||||||
|
|
||||||
|
// Логируем для отладки
|
||||||
|
console.log('Auth request:', { nickname, workplaceNumber })
|
||||||
|
|
||||||
|
res.json(response)
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/challenge/chains', (req, res) => {
|
router.get('/challenge/chains', (req, res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user