Skip to content

Commit 79992e9

Browse files
authored
Add migration guide for #2598 (#2647)
1 parent c166d5f commit 79992e9

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: Migration from 0.16.X to 0.17.X
3+
---
4+
5+
## What's new in 0.17.0?
6+
7+
### The `login` function parameters changed (username & password only)
8+
9+
:::info
10+
This change only affects you if you're using [username and password authentication](../auth/username-and-pass.md) with
11+
[custom auth UI](../auth/username-and-pass/create-your-own-ui.md). If you're using [email authentication](../auth/email.md),
12+
[social authentication](../auth/social-auth/overview.md), or our premade [Auth UI](../auth/ui.md) components,
13+
you don't need to take any action.
14+
:::
15+
16+
The `login` function, as imported from `wasp/client/auth`, has changed
17+
the way of calling it:
18+
19+
<Tabs>
20+
<TabItem value="before" label="Before">
21+
22+
```ts
23+
import { login } from 'wasp/client/auth'
24+
25+
await login(usernameValue, passwordValue)
26+
```
27+
28+
</TabItem>
29+
<TabItem value="after" label="After">
30+
31+
```ts
32+
import { login } from 'wasp/client/auth'
33+
34+
await login({ username: usernameValue, password: passwordValue })
35+
```
36+
37+
</TabItem>
38+
</Tabs>
39+
40+
This is to make it consistent with the `login` and `signup` calls in other
41+
authentication methods, which were already using this convention.
42+
43+
## How to migrate?
44+
45+
To migrate your Wasp app from 0.16.X to 0.17.X, follow these steps:
46+
47+
### 1. Change the parameters to the `login` function (username & password only)
48+
49+
:::info
50+
This change only affects you if you're using [username and password authentication](../auth/username-and-pass.md) with
51+
[custom auth UI](../auth/username-and-pass/create-your-own-ui.md). If you're using [email authentication](../auth/email.md),
52+
[social authentication](../auth/social-auth/overview.md), or our premade [Auth UI](../auth/ui.md) components,
53+
you don't need to take any action.
54+
:::
55+
56+
If you were using the `login` function (imported from `wasp/client/auth`),
57+
change its parameters from `login(usernameValue, passwordValue)` to
58+
`login({ username: usernameValue, password: passwordValue })`.
59+
60+
<Tabs>
61+
<TabItem value="before" label="Before">
62+
63+
```tsx title="src/components/MyLoginForm.tsx"
64+
import { login } from 'wasp/client/auth'
65+
66+
export const MyLoginForm = () => {
67+
const [usernameValue, setUsernameValue] = useState('')
68+
const [passwordValue, setPasswordValue] = useState('')
69+
70+
const handleSubmit = async (e) => {
71+
e.preventDefault()
72+
await login(usernameValue, passwordValue)
73+
// ...
74+
}
75+
76+
return <form onSubmit={handleSubmit}>{/* ... */}</form>
77+
}
78+
```
79+
80+
</TabItem>
81+
<TabItem value="after" label="After">
82+
83+
```tsx title="src/components/MyLoginForm.tsx"
84+
import { login } from 'wasp/client/auth'
85+
86+
export const MyLoginForm = () => {
87+
const [usernameValue, setUsernameValue] = useState('')
88+
const [passwordValue, setPasswordValue] = useState('')
89+
90+
const handleSubmit = async (e) => {
91+
e.preventDefault()
92+
await login({ username: usernameValue, password: passwordValue })
93+
// ...
94+
}
95+
96+
return <form onSubmit={handleSubmit}>{/* ... */}</form>
97+
}
98+
```
99+
100+
</TabItem>
101+
</Tabs>
102+
103+
It is possible that you were not using this function in your code.
104+
If you're instead using [the `<LoginForm>` component](../auth/ui.md#login-form),
105+
this change is already handled for you.
106+
107+
### 2. Enjoy your updated Wasp app
108+
109+
That's it!
110+
111+
You should now be able to run your app with the new Wasp 0.17.0.

web/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ module.exports = {
181181
collapsed: true,
182182
collapsible: true,
183183
items: [
184+
'migration-guides/migrate-from-0-16-to-0-17',
184185
'migration-guides/migrate-from-0-15-to-0-16',
185186
'migration-guides/migrate-from-0-14-to-0-15',
186187
'migration-guides/migrate-from-0-13-to-0-14',

0 commit comments

Comments
 (0)