registration page and such
This commit is contained in:
parent
83fdd5b79a
commit
3f9b05b1dd
|
@ -24,7 +24,10 @@ export const CoreLayout = () => {
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
{!user ? (
|
{!user ? (
|
||||||
<Login />
|
<Switch>
|
||||||
|
<Route path="/sign-up" component={NewUser} />
|
||||||
|
<Route path="/" component={Login} />
|
||||||
|
</Switch>
|
||||||
) : (
|
) : (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/users/new" component={NewUser} />
|
<Route path="/users/new" component={NewUser} />
|
||||||
|
|
|
@ -14,31 +14,33 @@ export const Login = () => {
|
||||||
const [form] = useForm<FormValues>()
|
const [form] = useForm<FormValues>()
|
||||||
|
|
||||||
const handleFinish = async ({ username, password }: FormValues) => {
|
const handleFinish = async ({ username, password }: FormValues) => {
|
||||||
const res = await appContext.post('/dj-rest-auth/login', {
|
try {
|
||||||
username,
|
const res = await appContext.post('/dj-rest-auth/login', {
|
||||||
password,
|
username,
|
||||||
})
|
password,
|
||||||
console.log(res)
|
})
|
||||||
|
console.log('logging in', res)
|
||||||
|
} catch (err) {
|
||||||
|
console.log('error logging in')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="login">
|
<Form onFinish={handleFinish} form={form}>
|
||||||
<Form onFinish={handleFinish} form={form}>
|
<h1>Log In</h1>
|
||||||
<h1>Log In</h1>
|
<FormItem label="username" name="username">
|
||||||
<FormItem label="username" name="username">
|
<Input />
|
||||||
<Input />
|
</FormItem>
|
||||||
</FormItem>
|
<FormItem label="Password" name="password">
|
||||||
<FormItem label="Password" name="password">
|
<Input type="password" />
|
||||||
<Input type="password" />
|
</FormItem>
|
||||||
</FormItem>
|
|
||||||
|
|
||||||
<div className="form-footer">
|
<div className="form-footer">
|
||||||
<Link to="/sign-up">No Account? Sign Up!</Link>
|
<Link to="/sign-up">No Account? Sign Up!</Link>
|
||||||
<Button type="primary" htmlType="submit">
|
<Button type="primary" htmlType="submit">
|
||||||
Log In!
|
Log In!
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import { Button, Form, Input, Layout, message } from 'antd'
|
import { Input, message } from 'antd'
|
||||||
import axios from 'axios'
|
import { useForm } from 'antd/lib/form/Form'
|
||||||
|
import FormItem from 'antd/lib/form/FormItem'
|
||||||
|
import { useAppContext } from '../../contexts/AppContext'
|
||||||
|
import { Button } from '../../elements/Button'
|
||||||
|
import { Form } from '../../elements/Form'
|
||||||
import { User } from '../../types'
|
import { User } from '../../types'
|
||||||
|
|
||||||
type NewUserForm = Omit<User, 'id'> & {
|
type NewUserForm = Omit<User, 'id'> & {
|
||||||
|
@ -8,7 +12,8 @@ type NewUserForm = Omit<User, 'id'> & {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NewUser = () => {
|
export const NewUser = () => {
|
||||||
const [form] = Form.useForm<NewUserForm>()
|
const api = useAppContext()
|
||||||
|
const [form] = useForm<NewUserForm>()
|
||||||
|
|
||||||
const handleFinish = (user: NewUserForm) => {
|
const handleFinish = (user: NewUserForm) => {
|
||||||
if (user.password1 !== user.password2) {
|
if (user.password1 !== user.password2) {
|
||||||
|
@ -16,23 +21,23 @@ export const NewUser = () => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.post(`/dj-rest-auth/registration/`, user)
|
api.post(`/dj-rest-auth/registration`, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form form={form} onFinish={handleFinish}>
|
<Form form={form} onFinish={handleFinish}>
|
||||||
<Form.Item label="username" name="username">
|
<FormItem label="username" name="username">
|
||||||
<Input></Input>
|
<Input></Input>
|
||||||
</Form.Item>
|
</FormItem>
|
||||||
<Form.Item label="email" name="email">
|
<FormItem label="email" name="email">
|
||||||
<Input type="email"></Input>
|
<Input type="email"></Input>
|
||||||
</Form.Item>
|
</FormItem>
|
||||||
<Form.Item label="password" name="password1">
|
<FormItem label="password" name="password1">
|
||||||
<Input minLength={8}></Input>
|
<Input minLength={8}></Input>
|
||||||
</Form.Item>
|
</FormItem>
|
||||||
<Form.Item label="confirm" name="password2">
|
<FormItem label="confirm" name="password2">
|
||||||
<Input></Input>
|
<Input></Input>
|
||||||
</Form.Item>
|
</FormItem>
|
||||||
<Button type="primary" htmlType="submit">
|
<Button type="primary" htmlType="submit">
|
||||||
Create
|
Create
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -19,8 +19,15 @@ class Command(BaseCommand):
|
||||||
email="tanner@westwinds.io",
|
email="tanner@westwinds.io",
|
||||||
password="toffee15").save()
|
password="toffee15").save()
|
||||||
|
|
||||||
|
self.stdout.write(User.objects.all())
|
||||||
|
self.stdout.write('Users Created!')
|
||||||
|
|
||||||
Account.objects.all().delete()
|
Account.objects.all().delete()
|
||||||
home = Account()
|
home = Account(name="home", details="home stacks",
|
||||||
|
income=4000, expenses=2000)
|
||||||
|
|
||||||
|
self.stdout.write(Account.objects.all().count())
|
||||||
|
self.stdout.write('Accounts Created!')
|
||||||
# create seed accounts
|
# create seed accounts
|
||||||
# Home Account
|
# Home Account
|
||||||
# $3000
|
# $3000
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
python manage.py createsuperuser --email admin@example.com --username admin
|
|
||||||
python manage.py makemigrations
|
python manage.py makemigrations
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
python manage.py seed
|
python manage.py seed
|
||||||
|
python manage.py createsuperuser --email admin@example.com --username admin
|
Loading…
Reference in New Issue
Block a user