mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-09-08 23:50:48 +02:00
243 lines
10 KiB
Templ
243 lines
10 KiB
Templ
package components
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
templ ForgotPassword(ctx context.Context, errorMessage string, successMessage string) {
|
|
@LayoutWithContext("Forgot Password", ctx) {
|
|
<div class="min-h-[calc(100vh-4rem)] flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 bg-secondary-50 dark:bg-secondary-900">
|
|
<div class="max-w-md w-full">
|
|
<div class="card overflow-hidden shadow-lg">
|
|
<div class="p-8">
|
|
<div class="text-center mb-8">
|
|
<div class="inline-flex items-center justify-center w-20 h-20 rounded-full bg-primary-100 dark:bg-primary-900 mb-4">
|
|
<i class="fas fa-key text-primary-600 dark:text-primary-400 text-3xl"></i>
|
|
</div>
|
|
<h2 class="text-3xl font-bold text-secondary-900 dark:text-secondary-100">Password Reset</h2>
|
|
<p class="mt-2 text-secondary-600 dark:text-secondary-400">Enter your email to receive a reset link</p>
|
|
</div>
|
|
|
|
if errorMessage != "" {
|
|
<div class="bg-red-100 dark:bg-red-900 border border-red-400 dark:border-red-700 text-red-700 dark:text-red-300 px-4 py-3 rounded-lg mb-6" role="alert">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-exclamation-circle mr-2"></i>
|
|
<span class="block sm:inline">{ errorMessage }</span>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
if successMessage != "" {
|
|
<div class="bg-green-100 dark:bg-green-900 border border-green-400 dark:border-green-700 text-green-700 dark:text-green-300 px-4 py-3 rounded-lg mb-6" role="alert">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-check-circle mr-2"></i>
|
|
<span class="block sm:inline">{ successMessage }</span>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<form
|
|
class="space-y-6"
|
|
method="POST"
|
|
action="/forgot-password"
|
|
x-data="{
|
|
email: '',
|
|
loading: false,
|
|
validate() {
|
|
return this.email && this.email.includes('@');
|
|
}
|
|
}">
|
|
<div>
|
|
<label for="email" class="block text-sm font-medium text-secondary-700 dark:text-secondary-300 mb-1">Email address</label>
|
|
<div class="relative">
|
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
|
<i class="fas fa-envelope text-secondary-400 dark:text-secondary-600"></i>
|
|
</div>
|
|
<input
|
|
id="email"
|
|
name="email"
|
|
type="email"
|
|
required
|
|
x-model="email"
|
|
class="form-input pl-10 w-full rounded-lg border-secondary-300 dark:border-secondary-700 dark:bg-secondary-800 dark:text-secondary-100 focus:ring-primary-500 focus:border-primary-500"
|
|
placeholder="you@example.com"/>
|
|
</div>
|
|
<p class="mt-2 text-sm text-secondary-500 dark:text-secondary-400">
|
|
We'll send a password reset link to this email
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<button
|
|
type="submit"
|
|
class="btn-primary w-full flex justify-center py-3"
|
|
x-bind:disabled="!validate()"
|
|
@click="loading = true">
|
|
<span x-show="!loading" class="flex items-center">
|
|
<i class="fas fa-paper-plane mr-2"></i>
|
|
Send Reset Link
|
|
</span>
|
|
<span x-show="loading" class="flex items-center">
|
|
<svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
</svg>
|
|
Processing...
|
|
</span>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="px-8 py-4 bg-secondary-50 dark:bg-secondary-800 border-t border-secondary-200 dark:border-secondary-700 text-center">
|
|
<p class="text-sm text-secondary-600 dark:text-secondary-400">
|
|
<a href="/login" class="text-primary-600 dark:text-primary-400 hover:text-primary-500 dark:hover:text-primary-300 flex items-center justify-center">
|
|
<i class="fas fa-arrow-left mr-2"></i>
|
|
Back to login
|
|
</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Security Notice -->
|
|
<div class="mt-8 text-center">
|
|
<div class="inline-flex items-center text-sm text-secondary-500 dark:text-secondary-400">
|
|
<i class="fas fa-shield-alt mr-2 text-primary-500"></i>
|
|
<span>Secure, encrypted connection</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
// Reset password page for when users click the link from their email
|
|
templ ResetPassword(ctx context.Context, token string, errorMessage string) {
|
|
@LayoutWithContext("Reset Password", ctx) {
|
|
<div class="min-h-[calc(100vh-4rem)] flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 bg-secondary-50 dark:bg-secondary-900">
|
|
<div class="max-w-md w-full">
|
|
<div class="card overflow-hidden shadow-lg">
|
|
<div class="p-8">
|
|
<div class="text-center mb-8">
|
|
<div class="inline-flex items-center justify-center w-20 h-20 rounded-full bg-primary-100 dark:bg-primary-900 mb-4">
|
|
<i class="fas fa-lock-open text-primary-600 dark:text-primary-400 text-3xl"></i>
|
|
</div>
|
|
<h2 class="text-3xl font-bold text-secondary-900 dark:text-secondary-100">Reset Password</h2>
|
|
<p class="mt-2 text-secondary-600 dark:text-secondary-400">Create a new password for your account</p>
|
|
</div>
|
|
|
|
if errorMessage != "" {
|
|
<div class="bg-red-100 dark:bg-red-900 border border-red-400 dark:border-red-700 text-red-700 dark:text-red-300 px-4 py-3 rounded-lg mb-6" role="alert">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-exclamation-circle mr-2"></i>
|
|
<span class="block sm:inline">{ errorMessage }</span>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<form
|
|
class="space-y-6"
|
|
method="POST"
|
|
action="/reset-password"
|
|
x-data="{
|
|
password: '',
|
|
confirmPassword: '',
|
|
loading: false,
|
|
validate() {
|
|
return this.password &&
|
|
this.password.length >= 8 &&
|
|
this.password === this.confirmPassword;
|
|
}
|
|
}">
|
|
<input type="hidden" name="token" value={token}/>
|
|
|
|
<div>
|
|
<label for="password" class="block text-sm font-medium text-secondary-700 dark:text-secondary-300 mb-1">New Password</label>
|
|
<div class="relative">
|
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
|
<i class="fas fa-key text-secondary-400 dark:text-secondary-600"></i>
|
|
</div>
|
|
<input
|
|
id="password"
|
|
name="password"
|
|
type="password"
|
|
required
|
|
x-model="password"
|
|
class="form-input pl-10 w-full rounded-lg border-secondary-300 dark:border-secondary-700 dark:bg-secondary-800 dark:text-secondary-100 focus:ring-primary-500 focus:border-primary-500"
|
|
placeholder="••••••••"/>
|
|
</div>
|
|
<p class="mt-1 text-sm text-secondary-500 dark:text-secondary-400">
|
|
Minimum 8 characters
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="confirm-password" class="block text-sm font-medium text-secondary-700 dark:text-secondary-300 mb-1">Confirm New Password</label>
|
|
<div class="relative">
|
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
|
<i class="fas fa-lock text-secondary-400 dark:text-secondary-600"></i>
|
|
</div>
|
|
<input
|
|
id="confirm-password"
|
|
name="confirm-password"
|
|
type="password"
|
|
required
|
|
x-model="confirmPassword"
|
|
class="form-input pl-10 w-full rounded-lg border-secondary-300 dark:border-secondary-700 dark:bg-secondary-800 dark:text-secondary-100 focus:ring-primary-500 focus:border-primary-500"
|
|
placeholder="••••••••"/>
|
|
</div>
|
|
<p class="mt-1 text-sm"
|
|
x-bind:class="{'text-red-500': confirmPassword && password !== confirmPassword, 'text-secondary-500 dark:text-secondary-400': !confirmPassword || password === confirmPassword}">
|
|
<span x-show="!confirmPassword || password === confirmPassword">
|
|
Passwords must match
|
|
</span>
|
|
<span x-show="confirmPassword && password !== confirmPassword">
|
|
<i class="fas fa-exclamation-triangle mr-1"></i>
|
|
Passwords do not match
|
|
</span>
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<button
|
|
type="submit"
|
|
class="btn-primary w-full flex justify-center py-3"
|
|
x-bind:disabled="!validate()"
|
|
@click="loading = true">
|
|
<span x-show="!loading" class="flex items-center">
|
|
<i class="fas fa-check-circle mr-2"></i>
|
|
Reset Password
|
|
</span>
|
|
<span x-show="loading" class="flex items-center">
|
|
<svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
</svg>
|
|
Processing...
|
|
</span>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="px-8 py-4 bg-secondary-50 dark:bg-secondary-800 border-t border-secondary-200 dark:border-secondary-700 text-center">
|
|
<p class="text-sm text-secondary-600 dark:text-secondary-400">
|
|
<a href="/login" class="text-primary-600 dark:text-primary-400 hover:text-primary-500 dark:hover:text-primary-300 flex items-center justify-center">
|
|
<i class="fas fa-arrow-left mr-2"></i>
|
|
Back to login
|
|
</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Security Notice -->
|
|
<div class="mt-8 text-center">
|
|
<div class="inline-flex items-center text-sm text-secondary-500 dark:text-secondary-400">
|
|
<i class="fas fa-shield-alt mr-2 text-primary-500"></i>
|
|
<span>Secure, encrypted connection</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
} |