mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-09-08 15:41:20 +02:00
- Upgraded `golang.org/x/crypto` to v0.36.0 and other indirect dependencies to their latest versions. - Added functionality to assign admin roles to users upon creation in the main application logic. - Introduced new templates for admin role management, including forms for creating and editing roles. - Removed deprecated admin tools template to streamline the admin interface. - Added audit logging for role changes to improve tracking and accountability.
124 lines
5.2 KiB
Templ
124 lines
5.2 KiB
Templ
package components
|
|
|
|
import "context"
|
|
|
|
type TwoFactorVerifyData struct {
|
|
ErrorMessage string
|
|
}
|
|
|
|
templ TwoFactorVerify(ctx context.Context, data TwoFactorVerifyData) {
|
|
@LayoutWithContext("Two-Factor Authentication", ctx) {
|
|
<div class="p-4 md:p-6 2xl:p-10">
|
|
<!-- Page Header -->
|
|
<div class="mb-6 flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
|
<h1 class="text-2xl font-bold text-gray-900 dark:text-white flex items-center">
|
|
<i class="fas fa-shield-alt w-6 h-6 mr-2 text-blue-500"></i>
|
|
Two-Factor Authentication
|
|
</h1>
|
|
</div>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400 mb-6">
|
|
Enter the verification code from your authenticator app to continue
|
|
</p>
|
|
|
|
if data.ErrorMessage != "" {
|
|
<div class="p-4 mb-6 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-red-900/50 dark:text-red-400 border border-red-200 dark:border-red-800" role="alert">
|
|
<div class="flex items-center">
|
|
<i class="fas fa-exclamation-circle flex-shrink-0 mr-2"></i>
|
|
<span>{ data.ErrorMessage }</span>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<!-- Verification Card -->
|
|
<div class="max-w-md mx-auto">
|
|
<div class="bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 dark:bg-gray-800">
|
|
<div class="p-4 border-b border-gray-200 dark:border-gray-700">
|
|
<div class="flex items-center space-x-3">
|
|
<div class="h-10 w-10 bg-blue-100 dark:bg-blue-900 rounded-full flex items-center justify-center">
|
|
<i class="fas fa-key text-blue-600 dark:text-blue-300"></i>
|
|
</div>
|
|
<div>
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">
|
|
Authentication Verification
|
|
</h3>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">Secure your account with 2FA</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="p-6">
|
|
<form
|
|
method="POST"
|
|
action="/login/verify"
|
|
class="space-y-4"
|
|
x-data="{ code: '', loading: false }"
|
|
@submit="loading = true">
|
|
<div>
|
|
<label for="code" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
|
Authentication Code
|
|
</label>
|
|
<div class="relative">
|
|
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
|
<i class="fas fa-key text-gray-400 dark:text-gray-500"></i>
|
|
</div>
|
|
<input
|
|
type="text"
|
|
id="code"
|
|
name="code"
|
|
x-model="code"
|
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
pattern="[0-9]*"
|
|
inputmode="numeric"
|
|
maxlength="6"
|
|
placeholder="Enter 6-digit code"
|
|
required/>
|
|
</div>
|
|
</div>
|
|
|
|
<button
|
|
type="submit"
|
|
class="w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
|
x-bind:disabled="code.length !== 6 || loading">
|
|
<span x-show="!loading" class="flex items-center justify-center">
|
|
<i class="fas fa-shield-alt mr-2"></i>
|
|
Verify
|
|
</span>
|
|
<span x-show="loading" class="flex items-center justify-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>
|
|
Verifying...
|
|
</span>
|
|
</button>
|
|
|
|
<div class="text-center">
|
|
<a href="/login/backup-code" class="text-sm font-medium text-blue-600 dark:text-blue-500 hover:underline">
|
|
Use a backup code instead
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="p-4 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 rounded-b-lg">
|
|
<div class="flex items-start text-sm text-gray-600 dark:text-gray-400">
|
|
<i class="fas fa-info-circle flex-shrink-0 mr-2 mt-0.5 text-blue-500"></i>
|
|
<p>
|
|
Lost your device? You can use one of your backup codes instead of the 6-digit code. Backup codes were provided when you set up 2FA.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Help Notice -->
|
|
<div class="mt-6 max-w-md mx-auto">
|
|
<div class="p-4 text-sm text-blue-800 rounded-lg bg-blue-50 dark:bg-blue-900/50 dark:text-blue-400 border border-blue-200 dark:border-blue-800 flex items-start">
|
|
<i class="fas fa-shield-alt flex-shrink-0 mr-3 mt-0.5"></i>
|
|
<div>
|
|
<h4 class="text-sm font-medium mb-1">Security Information</h4>
|
|
<p>Two-factor authentication adds an extra layer of security to your account. After entering your password, you'll need to provide a code from your authenticator app to verify your identity.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
} |