Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

696 B
Raw Blame
import { fail,redirect } from '@sveltejs/kit';
import { login,sessionCookie } from '../../../server/auth.mjs';
export const actions={
  default:async({request,cookies,getClientAddress,url})=>{
    const form=await request.formData();
    try {
      const token=await login(String(form.get('username') || ''),String(form.get('password') || ''),getClientAddress());
      if(!token)return fail(401,{error:'Invalid username or password'});
      cookies.set(sessionCookie,token,{path:'/',httpOnly:true,secure:url.protocol==='https:',sameSite:'strict',maxAge:8*3600});
    } catch(e) {return fail(e.status || 500,{error:e.status===429?e.message:'Login unavailable'});}
    redirect(303,'/');
  }
};