Documentation Index
Fetch the complete documentation index at: https://mintlify.com/BhushanBadhe39/SkinFirts/llms.txt
Use this file to discover all available pages before exploring further.
src/services/authService.js is the single source of truth for all authentication logic in SkinFirts. It sits between the UI layer and the raw API functions, coordinating three responsibilities in each operation: calling the relevant API function, persisting the result to AsyncStorage under the key @user_account_details, and keeping the Redux store in sync by dispatching the appropriate UserSlice action. All four exported functions are async and designed to be called with the Redux dispatch function obtained from useDispatch().
Imports
src/services/authService.js
Functions
signUpUser(formData, dispatch)
Registers a new user by calling createUser, then immediately persists the returned user object to AsyncStorage and dispatches setUser so the Redux store reflects the authenticated session. On success it always resolves to true.
Registration fields that match the user schema — typically
name, email, and password collected from the sign-up form. These are forwarded directly to createUser, which merges them with the pre-defined appointment seed fields before posting to the API.The Redux dispatch function obtained from
useDispatch(). Used to call setUser(newUser) after a successful registration, placing the user in the store and setting isLoggedIn = true.Always resolves to
true when the API call and storage write succeed. Any network or storage error will cause the promise to reject.- Calls
createUser(formData)→ POST./users/ - Writes
@user_account_detailstoAsyncStorage - Dispatches
setUser(newUser)to the Redux store
loginUser(email, password, dispatch)
Authenticates an existing user by fetching all users from the API, then finding the one whose email matches (case-insensitive, trimmed) and whose password matches exactly. If a matching user is found, the record is written to AsyncStorage and dispatched to the Redux store. Returns false if no match is found or if the network request fails.
The user’s email address. Compared case-insensitively after trimming leading and trailing whitespace —
" User@Example.com " will match "user@example.com" in the database.The user’s password. Compared with strict equality (
===) against the stored value; no hashing is applied at the client level.The Redux dispatch function obtained from
useDispatch(). Dispatches setUser(authUser) on a successful match.Resolves to
true when a matching user is found and the session is persisted. Resolves to false if no matching user is found or if an error is thrown during the fetch.- Calls
fetchUsers()→ GET./users - Writes
@user_account_detailstoAsyncStorageon success - Dispatches
setUser(authUser)on success
editUserDetails(id, updates, dispatch)
Updates an existing user’s profile by calling updateUser, then synchronises both AsyncStorage and the Redux store with the fresh data returned by the API. Returns true on success.
The user’s unique ID (the numeric string assigned by MockAPI, e.g.
"7"). Passed directly as the path parameter to updateUser.A partial user object containing only the fields to change. For example,
{ name: "Alex" } updates just the name without affecting other fields.The Redux dispatch function obtained from
useDispatch(). Dispatches setUser(newUser) with the server’s updated user object.Resolves to
true when the API call succeeds and the updated user is persisted. Returns false if updateUser returns a falsy value. Returns undefined if an error is caught (error is currently only logged).- Calls
updateUser(id, updates)→ PATCH./users/:id - Overwrites
@user_account_detailsinAsyncStoragewith the updated user - Dispatches
setUser(newUser)to the Redux store
logoutUser(dispatch)
Ends the authenticated session by removing @user_account_details from AsyncStorage and dispatching clearUser(), which resets the Redux user state to null and sets isLoggedIn to false.
The Redux dispatch function obtained from
useDispatch(). Dispatches clearUser() to wipe the user object from the store.Resolves once
AsyncStorage.removeItem completes and clearUser has been dispatched. Does not return a value.- Removes
@user_account_detailsfromAsyncStorage - Dispatches
clearUser()— setsstate.user.user = nullandstate.user.isLoggedIn = false