Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
feat: remember-me (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
clovertera authored Mar 20, 2024
1 parent 65d7830 commit ea85f9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
export interface SchemaAuth {
/** @default "123456" */
password?: string
/** @default false */
remember?: boolean
/** @default "demo" */
username?: string
}
Expand Down Expand Up @@ -518,7 +520,7 @@ export class Api<
},
params: RequestParams = {}
) =>
this.request<SchemaUserListResponse[], SchemaErrorResponse>({
this.request<SchemaUserListResponse, SchemaErrorResponse>({
path: `/api/v1/admin/users`,
method: 'GET',
query: query,
Expand Down
21 changes: 18 additions & 3 deletions src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ const LoginForm: React.FC = () => {
const [searchParams] = useSearchParams()
const [username, setUsername] = useState('demo')
const [password, setPassword] = useState('123456')
const [remember, setRemember] = useState(false)
const { run: login } = useRequest(
async () => {
const from = searchParams.get('from') ?? '/'
return Backend.auth.v1AuthLoginCreate(
{
username,
password
password,
remember
},
{
redirect_url: `${DOMAIN_HOST}${from}`
Expand Down Expand Up @@ -82,9 +84,22 @@ const LoginForm: React.FC = () => {
/>
</Col>
</Form.Group>

<Form.Group as={Row} className='mb-3'>
<Col sm={{ span: 10, offset: 2 }}>
<Button variant='primary' type='submit'>
<Col sm={{ span: 4, offset: 2 }}>
<Form.Check
type='checkbox'
label='Remember me'
onChange={() => {
setRemember(!remember)
}}
name='rememberme'
/>
<Button
style={{ marginTop: '10px' }}
variant='primary'
type='submit'
>
Submit
</Button>
</Col>
Expand Down

0 comments on commit ea85f9b

Please sign in to comment.