Skip to content

Commit 4966a68

Browse files
committed
Update authentication method in settings to use email only, and add explicit authentication backends. Modify Docker Compose command to include database migrations before starting Celery beat. Enhance LoginForm component to use refs for input fields and improve payload structure for login requests, adding diagnostic logs for better debugging.
1 parent 80718da commit 4966a68

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

backend/seculite_api/settings.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,24 @@
195195

196196
# django-allauth specific settings (examples, customize as needed)
197197
ACCOUNT_EMAIL_VERIFICATION = 'optional' # Can be 'mandatory', 'optional', or 'none'
198-
ACCOUNT_AUTHENTICATION_METHOD = 'username_email' # Allow login with username or email
198+
ACCOUNT_AUTHENTICATION_METHOD = 'email' # Use email ONLY for login
199199
ACCOUNT_EMAIL_REQUIRED = True
200-
ACCOUNT_USERNAME_REQUIRED = True # Or False, if you prefer email-only
201-
# ACCOUNT_USER_MODEL_USERNAME_FIELD = None # Set to None if ACCOUNT_USERNAME_REQUIRED is False
200+
ACCOUNT_USERNAME_REQUIRED = False # Username no longer required for login/signup
201+
ACCOUNT_USER_MODEL_USERNAME_FIELD = None # Explicitly state username field is not used
202202
# ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
203203
# ACCOUNT_LOGIN_ON_PASSWORD_RESET = True
204204
# For dj-rest-auth to work with JWT (if you switch from TokenAuth later)
205205
# REST_USE_JWT = True
206206
# DJOSER settings might go here if you were using Djoser instead
207207

208+
# Explicitly define Authentication Backends
209+
AUTHENTICATION_BACKENDS = (
210+
# Needed to login by username in Django admin, regardless of `allauth`
211+
'django.contrib.auth.backends.ModelBackend',
212+
# `allauth` specific authentication methods, such as login by e-mail
213+
'allauth.account.auth_backends.AuthenticationBackend',
214+
)
215+
208216
# Celery Configuration Options
209217
# ----------------------------
210218
# These are read by app.config_from_object('django.conf:settings', namespace='CELERY')

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ services:
9393
# Placeholder command for now, or adjust entrypoint to not require it if django-celery-beat is not yet installed.
9494
# For now, assuming it might be added back. If not, this service might not be started or its command changed.
9595
command: >
96-
celery_beat sh -c "rm -f /tmp/celerybeat.pid && \
96+
sh -c "poetry run python manage.py migrate --noinput && \
97+
rm -f /tmp/celerybeat.pid && \
9798
celery -A seculite_api beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler"
9899
volumes:
99100
- ./backend:/app

frontend/src/components/LoginForm.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<form @submit.prevent="handleLogin">
55
<div class="form-group">
66
<label for="login-email">Email or Username:</label>
7-
<input type="text" id="login-email" v.model="formData.email" required />
7+
<input type="text" id="login-email" v-model="formData.email" required ref="loginEmailInput" />
88
</div>
99
<div class="form-group">
1010
<label for="login-password">Password:</label>
11-
<input type="password" id="login-password" v.model="formData.password" required />
11+
<input type="password" id="login-password" v-model="formData.password" required ref="loginPasswordInput" />
1212
</div>
1313
<button type="submit" :disabled="isLoading">{{ isLoading ? 'Logging in...' : 'Login' }}</button>
1414
</form>
@@ -42,8 +42,20 @@ export default {
4242
this.message = '';
4343
this.isSuccess = false;
4444
45+
// --- DIAGNOSTIC LOGS ---
46+
const emailFromRef = this.$refs.loginEmailInput?.value;
47+
const passwordFromRef = this.$refs.loginPasswordInput?.value;
48+
console.log('Values from refs:', { email: emailFromRef, password: passwordFromRef });
49+
console.log('Values from formData before creating payload:', { email: this.formData.email, password: this.formData.password });
50+
// --- END DIAGNOSTIC LOGS ---
51+
4552
try {
46-
const response = await axios.post(`${AUTH_API_URL}/login/`, this.formData);
53+
const payload = {
54+
email: this.formData.email,
55+
password: this.formData.password
56+
};
57+
console.log('Sending login payload:', payload);
58+
const response = await axios.post(`${AUTH_API_URL}/login/`, payload);
4759
const token = response.data.key;
4860
if (token) {
4961
localStorage.setItem('authToken', token);

0 commit comments

Comments
 (0)