registration page and such

main
Elijah Lucian 3 years ago
parent 83fdd5b79a
commit 3f9b05b1dd
  1. 5
      frontend/src/CoreLayout.tsx
  2. 46
      frontend/src/pages/Login/index.tsx
  3. 29
      frontend/src/pages/NewUser/index.tsx
  4. 9
      server/server/api/management/commands/seed.py
  5. 4
      server/setup.sh

@ -24,7 +24,10 @@ export const CoreLayout = () => {
<main>
{!user ? (
<Login />
<Switch>
<Route path="/sign-up" component={NewUser} />
<Route path="/" component={Login} />
</Switch>
) : (
<Switch>
<Route path="/users/new" component={NewUser} />

@ -14,31 +14,33 @@ export const Login = () => {
const [form] = useForm<FormValues>()
const handleFinish = async ({ username, password }: FormValues) => {
const res = await appContext.post('/dj-rest-auth/login', {
username,
password,
})
console.log(res)
try {
const res = await appContext.post('/dj-rest-auth/login', {
username,
password,
})
console.log('logging in', res)
} catch (err) {
console.log('error logging in')
}
}
return (
<div className="login">
<Form onFinish={handleFinish} form={form}>
<h1>Log In</h1>
<FormItem label="username" name="username">
<Input />
</FormItem>
<FormItem label="Password" name="password">
<Input type="password" />
</FormItem>
<Form onFinish={handleFinish} form={form}>
<h1>Log In</h1>
<FormItem label="username" name="username">
<Input />
</FormItem>
<FormItem label="Password" name="password">
<Input type="password" />
</FormItem>
<div className="form-footer">
<Link to="/sign-up">No Account? Sign Up!</Link>
<Button type="primary" htmlType="submit">
Log In!
</Button>
</div>
</Form>
</div>
<div className="form-footer">
<Link to="/sign-up">No Account? Sign Up!</Link>
<Button type="primary" htmlType="submit">
Log In!
</Button>
</div>
</Form>
)
}

@ -1,5 +1,9 @@
import { Button, Form, Input, Layout, message } from 'antd'
import axios from 'axios'
import { Input, message } from 'antd'
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'
type NewUserForm = Omit<User, 'id'> & {
@ -8,7 +12,8 @@ type NewUserForm = Omit<User, 'id'> & {
}
export const NewUser = () => {
const [form] = Form.useForm<NewUserForm>()
const api = useAppContext()
const [form] = useForm<NewUserForm>()
const handleFinish = (user: NewUserForm) => {
if (user.password1 !== user.password2) {
@ -16,23 +21,23 @@ export const NewUser = () => {
return
}
axios.post(`/dj-rest-auth/registration/`, user)
api.post(`/dj-rest-auth/registration`, user)
}
return (
<Form form={form} onFinish={handleFinish}>
<Form.Item label="username" name="username">
<FormItem label="username" name="username">
<Input></Input>
</Form.Item>
<Form.Item label="email" name="email">
</FormItem>
<FormItem label="email" name="email">
<Input type="email"></Input>
</Form.Item>
<Form.Item label="password" name="password1">
</FormItem>
<FormItem label="password" name="password1">
<Input minLength={8}></Input>
</Form.Item>
<Form.Item label="confirm" name="password2">
</FormItem>
<FormItem label="confirm" name="password2">
<Input></Input>
</Form.Item>
</FormItem>
<Button type="primary" htmlType="submit">
Create
</Button>

@ -19,8 +19,15 @@ class Command(BaseCommand):
email="tanner@westwinds.io",
password="toffee15").save()
self.stdout.write(User.objects.all())
self.stdout.write('Users Created!')
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
# Home Account
# $3000

@ -1,5 +1,5 @@
python manage.py migrate
python manage.py createsuperuser --email admin@example.com --username admin
python manage.py makemigrations
python manage.py migrate
python manage.py seed
python manage.py seed
python manage.py createsuperuser --email admin@example.com --username admin
Loading…
Cancel
Save