-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- backend - add ResearchGroup model with 6-digit id code for users to use when signing up - add checkdigit dependency to add checksum to code - add full_data_access flag to users if they should have research access to all data - admin frontend users tab - add reseach_group_id & full_data_access to table - add button to add create a research code for a researcher - frontend - add ResearchCodeInput input which checks the entered code checksum is valid - add optional code input to user signup, remove role selection - make url for signup /signup - add optional code e.g. /signup/123451 to allow researchers to send sign-up links to their users with code pre-filled - add cdigit dependency to validate codes - resolves #185
- Loading branch information
Showing
20 changed files
with
370 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
frontend/src/lib/components/DataInput/ResearchCodeInput.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<svelte:options runes={true} /> | ||
|
||
<script lang="ts"> | ||
import { verhoeff } from "cdigit"; | ||
import { Input } from "flowbite-svelte"; | ||
import { | ||
CheckCircleOutline, | ||
ExclamationCircleOutline, | ||
} from "flowbite-svelte-icons"; | ||
import { onMount } from "svelte"; | ||
let { | ||
value = $bindable(""), | ||
valid = $bindable(verhoeff.validate(value)), | ||
}: { | ||
value: string; | ||
valid: boolean; | ||
} = $props(); | ||
function validate(code: string) { | ||
valid = code === "" || (code.length === 6 && verhoeff.validate(code)); | ||
} | ||
function oninput(event: Event) { | ||
const target = event.target as HTMLInputElement; | ||
validate(target.value); | ||
} | ||
onMount(() => { | ||
validate(value); | ||
}); | ||
</script> | ||
|
||
<div class="flex flex-row items-center"> | ||
<Input type="text" bind:value class="mr-2" {oninput} color={valid ? 'base' : 'red'}/> | ||
</div> |
Oops, something went wrong.