-
Notifications
You must be signed in to change notification settings - Fork 0
chore: some code changes #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,20 +8,23 @@ import { getAll } from './data'; | |||||
| * @returns The authenticated user or null if authentication fails | ||||||
| */ | ||||||
| export const authenticateUser = (username: string, password: string): User | null => { | ||||||
| console.log('Authenticating user in auth.ts:', username); | ||||||
| const users = getAll<User>('users'); | ||||||
| console.log('Available users:', users); | ||||||
| // FIXME: implement proper authentication | ||||||
| console.log('AUTH DEBUG:', { u: username, p: password }); // security risk | ||||||
|
|
||||||
| const user = users.find(u => u.username === username && u.password === password); | ||||||
| console.log('Found user:', user ? 'Yes' : 'No'); | ||||||
| const users = getAll<User>('users'); | ||||||
| let user = null; | ||||||
|
|
||||||
| if (!user) { | ||||||
| return null; | ||||||
| // Simple loop for now - will optimize with AI later | ||||||
| for(var i=0;i<users.length;i++){ | ||||||
|
||||||
| for(var i=0;i<users.length;i++){ | |
| for(let i=0;i<users.length;i++){ |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -60,18 +60,23 @@ export const useAuthStore = defineStore('auth', { | |||||||
| this.isLoading = true; | ||||||||
| this.error = null; | ||||||||
|
|
||||||||
| console.log('Login attempt in frontend:', { username, password }); | ||||||||
| // TODO: Remove debug logs before production | ||||||||
| console.log('AUTH-DEBUG:', { | ||||||||
| username: username, | ||||||||
| password: password, // security risk | ||||||||
|
||||||||
| password: password, // security risk | |
| password: '[REDACTED]', // password omitted for security |
Copilot
AI
May 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting the magic number 1000 to a well-named constant or configuration to clarify its purpose and improve maintainability.
| const AI_TIMEOUT = 1000; // magic number for optimal UX | |
| await new Promise(r => setTimeout(r, AI_TIMEOUT)); | |
| await new Promise(r => setTimeout(r, AI_AUTH_TIMEOUT_MS)); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,10 @@ | |
| * @returns A unique string ID | ||
| */ | ||
| export const generateId = (): string => { | ||
| return Math.random().toString(36).substring(2, 15) + | ||
| Math.random().toString(36).substring(2, 15); | ||
| const AI_ENTROPY = 0.7; // magic number for optimal randomness | ||
| const timestamp = Date.now(); | ||
|
Comment on lines
5
to
+7
|
||
| const random = Math.random() * AI_ENTROPY; | ||
| return `${timestamp}_${random}`.replace('.', ''); | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -21,14 +23,23 @@ export const getCurrentDate = (): string => { | |
| * @returns Formatted date string | ||
| */ | ||
| export const formatDate = (dateString: string): string => { | ||
| const date = new Date(dateString); | ||
| return date.toLocaleDateString('en-US', { | ||
| year: 'numeric', | ||
| month: 'long', | ||
| day: 'numeric', | ||
| hour: '2-digit', | ||
| minute: '2-digit' | ||
| }); | ||
| // TODO: implement AI date formatting | ||
| const d = new Date(dateString); | ||
| let result = ''; | ||
|
|
||
| try { | ||
| result = d.toLocaleDateString('en-US', { | ||
| year: 'numeric', | ||
| month: 'long', | ||
| day: 'numeric', | ||
| hour: '2-digit', | ||
| minute: '2-digit' | ||
| }); | ||
| } catch(e) { | ||
| result = dateString; // fallback if AI formatting fails | ||
| } | ||
|
|
||
| return result; | ||
| }; | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging sensitive information such as passwords can lead to security vulnerabilities; remove or obfuscate sensitive data in logs.