mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-10 01:24:20 +02:00
Fix logging in
This commit is contained in:
parent
5cbb5811ec
commit
d5ae2fe5f8
@ -24,7 +24,8 @@ export const volunteerAdd = expressAccessor.add()
|
|||||||
export const volunteerSet = expressAccessor.set()
|
export const volunteerSet = expressAccessor.set()
|
||||||
|
|
||||||
export const volunteerLogin = expressAccessor.get(
|
export const volunteerLogin = expressAccessor.get(
|
||||||
async (list: Volunteer[], body: RequestBody): Promise<VolunteerLogin> => {
|
async (list: Volunteer[], bodyArray: RequestBody): Promise<VolunteerLogin> => {
|
||||||
|
const [body] = bodyArray
|
||||||
const volunteer = getByEmail(list, body.email)
|
const volunteer = getByEmail(list, body.email)
|
||||||
if (!volunteer) {
|
if (!volunteer) {
|
||||||
throw Error("Il n'y a aucun bénévole avec cet email")
|
throw Error("Il n'y a aucun bénévole avec cet email")
|
||||||
@ -55,7 +56,9 @@ export const volunteerLogin = expressAccessor.get(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const lastForgot: { [id: string]: number } = {}
|
const lastForgot: { [id: string]: number } = {}
|
||||||
export const volunteerForgot = expressAccessor.set(async (list: Volunteer[], body: RequestBody) => {
|
export const volunteerForgot = expressAccessor.set(
|
||||||
|
async (list: Volunteer[], bodyArray: RequestBody) => {
|
||||||
|
const [body] = bodyArray
|
||||||
const volunteer = getByEmail(list, body.email)
|
const volunteer = getByEmail(list, body.email)
|
||||||
if (!volunteer) {
|
if (!volunteer) {
|
||||||
throw Error("Il n'y a aucun bénévole avec cet email")
|
throw Error("Il n'y a aucun bénévole avec cet email")
|
||||||
@ -83,17 +86,23 @@ export const volunteerForgot = expressAccessor.set(async (list: Volunteer[], bod
|
|||||||
message: `Un nouveau mot de passe t'a été envoyé par email. Regarde bien dans tes spams, ils pourrait y être :/`,
|
message: `Un nouveau mot de passe t'a été envoyé par email. Regarde bien dans tes spams, ils pourrait y être :/`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
export const volunteerNotifsSet = expressAccessor.set(
|
export const volunteerNotifsSet = expressAccessor.set(
|
||||||
async (list: Volunteer[], body: RequestBody, id: number) => {
|
async (list: Volunteer[], body: RequestBody, id: number) => {
|
||||||
|
const requestedId = +body[0]
|
||||||
|
if (requestedId !== id) {
|
||||||
|
throw Error(`On ne peut acceder qu'à ses propres notifs`)
|
||||||
|
}
|
||||||
|
const notifChanges = body[1]
|
||||||
const volunteer = list.find((v) => v.id === id)
|
const volunteer = list.find((v) => v.id === id)
|
||||||
if (!volunteer) {
|
if (!volunteer) {
|
||||||
throw Error(`Il n'y a aucun bénévole avec cet identifiant ${id}`)
|
throw Error(`Il n'y a aucun bénévole avec cet identifiant ${id}`)
|
||||||
}
|
}
|
||||||
const newVolunteer = _.cloneDeep(volunteer)
|
const newVolunteer = _.cloneDeep(volunteer)
|
||||||
|
|
||||||
_.assign(newVolunteer, _.pick(body[1], _.keys(newVolunteer)))
|
_.assign(newVolunteer, _.pick(notifChanges, _.keys(newVolunteer)))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
toDatabase: newVolunteer,
|
toDatabase: newVolunteer,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user