Well, I want to authenticate with my backend server using credentials providers but I have no clues, so ! TwT
TomEverson opened this issue · comments
Frontend ( Svelte Code )
<script>
import { signIn } from "@astro-auth/client";
</script>
<button type="submit" class="submit border border-black rounded-xl text-2xl font-normal leading-10 w-[400px] h-[59px] flex flex-row items-center justify-center bg-gray-400 disabled:bg-red-400"
on:click|preventDefault={() => {
signIn({
provider: "credential",
login: {
email: "test@gmail.com",
password: "test-password",
},
});
}}
>
Log-In
</button>
</form>
<p>Don't have an account?<a href="../create-account" style="color: #5A4FF3;"> Sign-Up</a></p>
</div>
</div>
API route
import AstroAuth from "@astro-auth/core";
// Import the Credential provider(s)
import { CredentialProvider } from "@astro-auth/providers";
export const all = AstroAuth({
authProviders: [
CredentialProvider({
authorize: "http://localhost:8000/login"
}),
],
});
Edit your api route like this
CredentialProvider({
// Here, we are simply checking if the email matches and allow the user to login
authorize: async (properties) => {
if (properties.email == "osadavidath@gmail.com") {
return properties;
}
//if conditional fail, failed to signin
return null;
},
}),
change with your own conditional