-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Moving logic from templates to libs #2989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 11 commits
b4e1769
8b708bb
49d979c
a352e57
97a6838
121901f
4e248ae
ac9d038
3840e58
db8aaeb
ac55723
6dfc790
7a84ae8
e8c955a
f0cfe95
2f77c1c
36b720c
083fecb
9a70244
b450ef2
00e6fbf
90eab52
6b6b2f7
3c818cd
7e76f65
43aaac5
1073098
828b096
aa05550
c4099d5
82f258c
c3454d7
22958f5
9f3a53a
a06e101
1e1d36c
190e789
fb548b0
48dfe49
58fe09a
bd54fb4
ef0182b
8851649
9fc9e17
8a4ce86
a88c972
5bd2680
4f0a8e7
211a04b
03066ee
ae1255b
b9ace98
f50e54b
2478372
cd5347c
438314a
10803d4
52fe7f2
f2df493
b234395
669faca
4e6ddbb
5f3078e
b0417a3
a695db1
cd6940b
5771e1f
4b5a1c7
133e837
bcab437
f1a21e0
563c00c
7c08e2d
e2d5eda
12b925a
0fae11c
ac02cca
6ecacc3
075cc77
1587964
279d1b4
38fdbe0
0bec41e
68a4035
500f574
2dc8399
97f1a49
d07b368
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import { useContext } from 'react' | ||
import { useForm } from 'react-hook-form' | ||
import { useAuthContext } from '@wasp.sh/libs-auth/client' | ||
|
||
import { requestPasswordReset } from '../../../email/actions/passwordReset.js' | ||
import { Form, FormItemGroup, FormLabel, FormInput, SubmitButton, FormError } from '../Form' | ||
import { AuthContext } from '../../Auth' | ||
|
||
|
||
// PRIVATE API | ||
export const ForgotPasswordForm = () => { | ||
const { register, handleSubmit, reset, formState: { errors } } = useForm<{ email: string }>() | ||
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useContext(AuthContext) | ||
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useAuthContext() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When doing big PRs like this, I advise staying away from all other changes, no matter how minor. This can stay but we should apply the principle to future PRs. Btw, update the public API table if necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually think it's good that he made this change, it's scoped enough to be a demonstration and a proof that it works, without big changes otherwise. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a POC where I had to get a feel for how the lib will ship browser code - I didn't want to ship the system which would be completely wrong for browser stuff. I can remove this bit if you want and add it in a separate PR. |
||
|
||
const onSubmit = async (data) => { | ||
setIsLoading(true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { createCreateJWT, createValidateJWT } from "@wasp.sh/libs-auth"; | ||
import { createJWTHelpers } from "@wasp.sh/libs-auth"; | ||
|
||
import { config } from "wasp/server"; | ||
|
||
const JWT_SECRET = new TextEncoder().encode(config.auth.jwtSecret); | ||
const JWT_ALGORITHM = "HS256"; | ||
|
||
// PRIVATE API | ||
export const createJWT = createCreateJWT(JWT_SECRET, JWT_ALGORITHM); | ||
|
||
// PRIVATE API | ||
export const validateJWT = createValidateJWT(JWT_SECRET, JWT_ALGORITHM); | ||
export const { createJWT, validateJWT } = createJWTHelpers( | ||
JWT_SECRET, | ||
JWT_ALGORITHM, | ||
); | ||
|
||
// PRIVATE API | ||
export { TimeSpan } from "@wasp.sh/libs-auth"; | ||
infomiho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
Martinsos marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
# Testing Libs Locally | ||
|
||
Run `tools/install_libs_to_data_dir.sh` to compile the libs and copy | ||
them into `data/`. Then you can use `cabal run` as normal, or you can | ||
`cabal install` and then use `wasp-cli`. | ||
them into `data/`. Then you can use `./run wasp-cli` as normal. You can run | ||
`./run install` which will run the script before installing the | ||
Wasp CLI. | ||
|
||
# Adding a New Package | ||
|
||
Create a directory in this folder to contain the new package. It should have a | ||
`pack-and-copy` script inside `package.json`. | ||
Create a directory in this folder to contain the new package. It should contain a | ||
`prepare` script that will be run to prepare the package for use e.g. to build | ||
the package. | ||
|
||
The package will be packaged using `npm pack` and the resulting tarball will | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a note to make sure to tweak the |
||
be copied to `data/libs/` by the `tools/install_libs_to_data_dir.sh` script. | ||
|
||
# CI Builds/Release | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Wasp Auth Library | ||
infomiho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Based on a `unbuild` template. | ||
Based on the default `tsdown` template. |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.