Changeset 37307aa
- Timestamp:
- 04/21/26 18:07:57 (3 months ago)
- Branches:
- master
- Children:
- 89156c1
- Parents:
- c4c43f3
- Files:
-
- 10 added
- 4 edited
-
.idea/.gitignore (added)
-
.idea/compiler.xml (added)
-
.idea/copilot.data.migration.ask2agent.xml (added)
-
.idea/encodings.xml (added)
-
.idea/inspectionProfiles/Project_Default.xml (added)
-
.idea/jarRepositories.xml (added)
-
.idea/misc.xml (added)
-
.idea/modules.xml (added)
-
.idea/trekr.iml (added)
-
.idea/vcs.xml (added)
-
backend/src/main/java/com/trekr/backend/BackendApplication.java (modified) (2 diffs)
-
db-scripts/ddl.sql (modified) (1 diff)
-
db-scripts/dml.sql (modified) (2 diffs)
-
frontend/src/pages/Register/Register.jsx (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
backend/src/main/java/com/trekr/backend/BackendApplication.java
rc4c43f3 r37307aa 4 4 import org.springframework.boot.SpringApplication; 5 5 import org.springframework.boot.autoconfigure.SpringBootApplication; 6 7 import java.nio.file.Files; 8 import java.nio.file.Path; 9 import java.nio.file.Paths; 6 10 7 11 @SpringBootApplication … … 60 64 for (String[] candidate : candidates) { 61 65 try { 66 Path envPath = Paths.get(candidate[0], candidate[1]).normalize(); 67 if (!Files.isRegularFile(envPath)) { 68 continue; 69 } 70 62 71 Dotenv loaded = Dotenv.configure() 63 .directory( candidate[0])64 .filename( candidate[1])72 .directory(envPath.getParent().toString()) 73 .filename(envPath.getFileName().toString()) 65 74 .ignoreIfMissing() 66 75 .load(); 67 if (loaded != null && !loaded.entries().isEmpty()) {76 if (loaded != null) { 68 77 dotenv = loaded; 69 78 break; -
db-scripts/ddl.sql
rc4c43f3 r37307aa 21 21 CREATE TABLE USERS ( 22 22 user_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, 23 email TEXT NOT NULL ,24 username TEXT NOT NULL ,23 email TEXT NOT NULL UNIQUE, 24 username TEXT NOT NULL UNIQUE, 25 25 password TEXT NOT NULL 26 26 ); -
db-scripts/dml.sql
rc4c43f3 r37307aa 2 2 3 3 INSERT INTO USERS (user_id, email, username, password) VALUES 4 (1, 'dimitar@example.com', 'dimitar_arsov', ' $2a$10$examplehash1'),5 (2, 'filip@example.com', 'filip_gavrilovski', ' $2a$10$examplehash2'),6 (3, 'marko@example.com', 'marko_markovski', ' $2a$10$examplehash3'),4 (1, 'dimitar@example.com', 'dimitar_arsov', '1234'), 5 (2, 'filip@example.com', 'filip_gavrilovski', '1234'), 6 (3, 'marko@example.com', 'marko_markovski', '1234'), 7 7 (4, 'andrej.shumanovski@gmail.com', 'andrej_shumanovski', '1234'), 8 8 (5, 'angelovski.mario222@gmail.com', 'angelovski_mario', '1234'), 9 (6, 'ana@example.com', 'ana_ilievska', ' $2a$10$examplehash6'),10 (7, 'petar@example.com', 'petar_stojanov', ' $2a$10$examplehash7'),11 (8, 'elena@example.com', 'elena_ristova', ' $2a$10$examplehash8'),12 (9, 'stefan@example.com', 'stefan_nikolov', ' $2a$10$examplehash9'),13 (10, 'ivana@example.com', 'ivana_karapandzova', ' $2a$10$examplehash10'),9 (6, 'ana@example.com', 'ana_ilievska', '1234'), 10 (7, 'petar@example.com', 'petar_stojanov', '1234'), 11 (8, 'elena@example.com', 'elena_ristova', '1234'), 12 (9, 'stefan@example.com', 'stefan_nikolov', '1234'), 13 (10, 'ivana@example.com', 'ivana_karapandzova', '1234'), 14 14 (11, 'nikola@example.com', 'nikola_ivanov', '1234'), 15 15 (12, 'marija@example.com', 'marija_petrova', '1234'), … … 193 193 194 194 INSERT INTO TRAINING_SESSIONS (training_id, training_user_id, duration, calories, date, type) VALUES 195 (1, 1, 60, 500, '2026-02-01', ' Running'),196 (2, 2, 45, 400, '2026-02-01', ' Cycling'),197 (3, 3, 30, 300, '2026-02-01', ' Swimming'),198 (4, 4, 50, 420, '2026-02-02', ' HIIT'),199 (5, 5, 40, 350, '2026-02-02', ' Strength'),200 (6, 6, 35, 280, '2026-02-02', ' Yoga'),201 (7, 7, 55, 520, '2026-02-03', ' Running'),202 (8, 8, 45, 390, '2026-02-03', ' Cycling'),203 (9, 9, 30, 260, '2026-02-03', ' Rowing'),204 (10, 10, 60, 480, '2026-02-04', ' Swimming'),205 (11, 11, 50, 430, '2026-02-05', ' Strength'),206 (12, 12, 40, 310, '2026-02-05', ' Yoga'),207 (13, 13, 60, 540, '2026-02-06', ' Running'),208 (14, 14, 35, 260, '2026-02-06', ' Pilates'),209 (15, 15, 45, 390, '2026-02-07', ' Cycling'),210 (16, 16, 55, 460, '2026-02-07', ' HIIT'),211 (17, 17, 30, 240, '2026-02-08', ' Rowing'),212 (18, 18, 65, 520, '2026-02-08', ' Swimming'),213 (19, 19, 50, 440, '2026-02-09', ' Running'),214 (20, 20, 45, 370, '2026-02-09', ' Strength'),215 (21, 11, 35, 300, '2026-02-12', ' Cycling'),216 (22, 13, 30, 260, '2026-02-12', ' Core'),217 (23, 15, 70, 600, '2026-02-13', ' Long Run'),218 (24, 17, 40, 320, '2026-02-13', ' Strength');195 (1, 1, 60, 500, '2026-02-01', 'running'), 196 (2, 2, 45, 400, '2026-02-01', 'cycling'), 197 (3, 3, 30, 300, '2026-02-01', 'swimming'), 198 (4, 4, 50, 420, '2026-02-02', 'hiit'), 199 (5, 5, 40, 350, '2026-02-02', 'strength'), 200 (6, 6, 35, 280, '2026-02-02', 'yoga'), 201 (7, 7, 55, 520, '2026-02-03', 'running'), 202 (8, 8, 45, 390, '2026-02-03', 'cycling'), 203 (9, 9, 30, 260, '2026-02-03', 'rowing'), 204 (10, 10, 60, 480, '2026-02-04', 'swimming'), 205 (11, 11, 50, 430, '2026-02-05', 'strength'), 206 (12, 12, 40, 310, '2026-02-05', 'yoga'), 207 (13, 13, 60, 540, '2026-02-06', 'running'), 208 (14, 14, 35, 260, '2026-02-06', 'pilates'), 209 (15, 15, 45, 390, '2026-02-07', 'cycling'), 210 (16, 16, 55, 460, '2026-02-07', 'hiit'), 211 (17, 17, 30, 240, '2026-02-08', 'rowing'), 212 (18, 18, 65, 520, '2026-02-08', 'swimming'), 213 (19, 19, 50, 440, '2026-02-09', 'running'), 214 (20, 20, 45, 370, '2026-02-09', 'strength'), 215 (21, 11, 35, 300, '2026-02-12', 'cycling'), 216 (22, 13, 30, 260, '2026-02-12', 'strength'), 217 (23, 15, 70, 600, '2026-02-13', 'running'), 218 (24, 17, 40, 320, '2026-02-13', 'strength'); 219 219 220 220 SELECT setval( -
frontend/src/pages/Register/Register.jsx
rc4c43f3 r37307aa 21 21 setError(""); 22 22 setIsSubmitting(true); 23 24 const normalizedEmail = email.trim().toLowerCase(); 25 const normalizedUsername = username.trim(); 26 const normalizedPassword = password; 27 28 if (normalizedUsername.length < 3 || normalizedUsername.length > 50) { 29 setError("Username must be between 3 and 50 characters"); 30 setIsSubmitting(false); 31 return; 32 } 33 34 if (normalizedPassword.length < 6) { 35 setError("Password must be at least 6 characters"); 36 setIsSubmitting(false); 37 return; 38 } 39 23 40 try { 24 41 const res = await api.post("/auth/register", { 25 email ,26 username ,27 password ,42 email: normalizedEmail, 43 username: normalizedUsername, 44 password: normalizedPassword, 28 45 }); 29 46 localStorage.setItem("authToken", res.data.token); … … 38 55 navigate("/dashboard"); 39 56 } catch (err) { 57 const fieldErrors = err?.response?.data?.errors ?? {}; 58 const firstFieldError = Object.values(fieldErrors)[0]; 40 59 const message = 60 firstFieldError || 41 61 err?.response?.data?.message || 42 Object.values(err?.response?.data?.errors ?? {})[0] ||43 62 "Registration failed"; 44 63 setError(message); … … 75 94 onChange={(e) => setUsername(e.target.value)} 76 95 autoComplete="username" 96 minLength={3} 97 maxLength={50} 77 98 required 78 99 /> … … 86 107 onChange={(e) => setPassword(e.target.value)} 87 108 autoComplete="new-password" 109 minLength={6} 88 110 required 89 111 />
Note:
See TracChangeset
for help on using the changeset viewer.
