registration page and such
This commit is contained in:
		@@ -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
 | 
			
		||||
		Reference in New Issue
	
	Block a user