commit before i break things
This commit is contained in:
@@ -50,7 +50,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
let subscribedSubjectIds: string[] = [];
|
||||
if (res.userId) {
|
||||
try {
|
||||
const dto = await authApi.getUser(res.userId, res.token);
|
||||
const dto = await authApi.getUser( res.token);
|
||||
subscribedSubjectIds = dto.subjectSet?.map((s) => s.id) ?? [];
|
||||
} catch {
|
||||
// aaaa
|
||||
@@ -67,7 +67,10 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
const register = async (payload: RegisterPayload) => {
|
||||
await authApi.register(payload);
|
||||
await login({ email: payload.email, password: payload.password });
|
||||
await login({
|
||||
email: payload.email.trim(),
|
||||
password: payload.password.trim(),
|
||||
});
|
||||
};
|
||||
|
||||
const updateUser = async (newEmail?: string, newPassword?: string) => {
|
||||
@@ -91,7 +94,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
const subscribe = async (subjectId: string) => {
|
||||
if (!user) return;
|
||||
const dto = await subscriptionsApi.subscribe(user.id, subjectId, user.token);
|
||||
const dto = await subscriptionsApi.subscribe( subjectId, user.token);
|
||||
const updated = {
|
||||
...user,
|
||||
subscribedSubjectIds: dto.subjectSet?.map((s) => s.id) ?? [...user.subscribedSubjectIds, subjectId],
|
||||
@@ -101,7 +104,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
const unsubscribe = async (subjectId: string) => {
|
||||
if (!user) return;
|
||||
const dto = await subscriptionsApi.unsubscribe(user.id, subjectId, user.token);
|
||||
const dto = await subscriptionsApi.unsubscribe( subjectId, user.token);
|
||||
const updated = {
|
||||
...user,
|
||||
subscribedSubjectIds: dto.subjectSet?.map((s) => s.id) ?? user.subscribedSubjectIds.filter((id) => id !== subjectId),
|
||||
|
||||
Reference in New Issue
Block a user