fix: register store token

This commit is contained in:
Nicolas Meienberger 2022-11-01 15:42:47 +01:00
parent 93188b662c
commit e8d7edbe57
2 changed files with 13 additions and 3 deletions

View file

@ -1,3 +1,4 @@
import { useApolloClient } from '@apollo/client';
import { useToast } from '@chakra-ui/react';
import React, { useState } from 'react';
import { useRegisterMutation } from '../../../generated/graphql';
@ -5,6 +6,7 @@ import AuthFormLayout from '../components/AuthFormLayout';
import RegisterForm from '../components/RegisterForm';
const Onboarding: React.FC = () => {
const client = useApolloClient();
const toast = useToast();
const [register] = useRegisterMutation({ refetchQueries: ['Me'] });
const [loading, setLoading] = useState(false);
@ -24,7 +26,13 @@ const Onboarding: React.FC = () => {
const handleRegister = async (values: { email: string; password: string }) => {
try {
setLoading(true);
await register({ variables: { input: { username: values.email, password: values.password } } });
const { data } = await register({ variables: { input: { username: values.email, password: values.password } } });
if (data?.register?.token) {
localStorage.setItem('token', data.register.token);
}
await client.refetchQueries({ include: ['Me'] });
} catch (error) {
handleError(error);
} finally {

View file

@ -81,10 +81,12 @@ function kill_watcher() {
# If multiline kill each pid
if [[ $watcher_pid == *" "* ]]; then
for pid in $watcher_pid; do
kill -9 "$pid"
# shellcheck disable=SC2086
kill -9 $pid
done
else
kill -9 "$watcher_pid"
# shellcheck disable=SC2086
kill -9 $watcher_pid
fi
fi
}