Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
28c85be
test commit
fanden Aug 27, 2025
786d1a5
Update README.md
magnusgit1 Aug 27, 2025
3578fd7
Added checks for password and email
Richard-Persson Sep 3, 2025
03fc428
created profileController, added mobile field to Profile
fanden Sep 3, 2025
7536b5f
Changed logic for if statements
Richard-Persson Sep 3, 2025
136e3c5
createProfile now correctly handles errors
fanden Sep 3, 2025
dae7c7d
Added error message for name validation
fanden Sep 3, 2025
a7b6174
Fixed login
Sep 5, 2025
797a1d7
Merge pull request #6 from emazau/POST-LOGIN
magnusgit1 Sep 5, 2025
db42e07
Merge pull request #5 from boolean-uk/1-api--post--register-new-user
magnusgit1 Sep 5, 2025
3b67eeb
Updated Profile class, ProfileController and test profiles in Main to…
fanden Sep 8, 2025
4281e1b
Fixed Profile class
fanden Sep 8, 2025
3d24685
Merge pull request #8 from boolean-uk/4-api---post---endpoint-for-pro…
magnusgit1 Sep 8, 2025
37e04c9
added patchmapping to ProfileController
magnusgit1 Sep 10, 2025
1453e98
Added a course model, and a link between Cohort and courses
Richard-Persson Sep 11, 2025
c5da59d
fixed patch, added foreign keys to profile and user
magnusgit1 Sep 11, 2025
500226d
Added new Comments table and added GET POST PUT AND DELETE to COMMENTs
Sep 11, 2025
d38a217
fixed foreign-keys in profile and added cohort as part of the user-patch
magnusgit1 Sep 11, 2025
0cbba95
Added Like attribute and post and delete mapping for increase and dec…
Sep 11, 2025
2676ee6
Merge pull request #16 from boolean-uk/12-api---create-course-model-a…
magnusgit1 Sep 11, 2025
c820147
Changed cohort and user model, + cohortController
Richard-Persson Sep 11, 2025
a2f0e8b
fixed name-issue in userId and fixed order of arguments in profile-co…
magnusgit1 Sep 12, 2025
6c4f00f
updated if statement
Richard-Persson Sep 12, 2025
5f0cbc0
Merge pull request #19 from boolean-uk/FIX/update-data-and-endpoint-f…
magnusgit1 Sep 12, 2025
d1c3402
Merge pull request #18 from boolean-uk/COMMENT-GETPUTPOSTDELETE
magnusgit1 Sep 12, 2025
4bc215d
Merge pull request #23 from boolean-uk/ADD-LIKE-ATTRIBUTE
magnusgit1 Sep 12, 2025
dd5ee43
Merge branch 'main' into 7-api---get-cohorts-page---student
Richard-Persson Sep 12, 2025
55acadc
Updated JsonIgnoreProperties typo to avoid infinite loop
Richard-Persson Sep 12, 2025
50ed2ce
Merge pull request #22 from boolean-uk/7-api---get-cohorts-page---stu…
magnusgit1 Sep 12, 2025
09e7319
Fixed bugs
Sep 12, 2025
6b63b4f
Fixed json ignore properties
Richard-Persson Sep 15, 2025
c2b7eb9
Merge pull request #24 from boolean-uk/quick_fix
emazau Sep 16, 2025
3565f74
minor changes made in ProfileController to give correct data in DB
moueedAli Sep 16, 2025
cbad252
Merge pull request #25 from boolean-uk/FIX/minor-changes-in-profileCo…
emazau Sep 16, 2025
f7d67ca
fixed variables in record class
magnusgit1 Sep 16, 2025
ff8f2dc
Merge pull request #28 from boolean-uk/FIX/minor-change-in-profile-co…
emazau Sep 16, 2025
950f9b6
Added Endpoint for Student profile
Sep 16, 2025
5d9384c
Added encoder for password
Sep 16, 2025
f9b2db8
Added check for student-role
Sep 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ out/
### VS Code ###
.vscode/

### Project specific
application.yml
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ Once you are fully up to speed and working on the project it is perfectly accept

Once you have your teams set up, enjoy working on the code.

We look forward to seeing what you manage to produce from it!
We look forward to seeing what you manage to produce from it!

----Test access Magnus-----
31 changes: 29 additions & 2 deletions src/main/java/com/booleanuk/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -69,7 +70,20 @@ public void run(String... args) {
}
Profile studentProfile;
if (!this.profileRepository.existsById(1)) {
studentProfile = this.profileRepository.save(new Profile(studentUser, "Joe", "Bloggs", "Hello world!", "student1"));
studentProfile = this.profileRepository.save(new Profile(studentUser,
"Joe",
"Bloggs",
"usrname",
"mygit",
"95555",
"Hello world!",
studentRole,
"Backend Development",
cohort,
LocalDate.of(2025, 9, 8),
LocalDate.of(2026, 9, 8),
"fnwjkdnfj32.,."
));
} else {
studentProfile = this.profileRepository.findById(1).orElse(null);
}
Expand All @@ -84,7 +98,20 @@ public void run(String... args) {
}
Profile teacherProfile;
if (!this.profileRepository.existsById(2)) {
teacherProfile = this.profileRepository.save(new Profile(teacherUser, "Rick", "Sanchez", "Hello there!", "teacher1"));
teacherProfile = this.profileRepository.save(new Profile(teacherUser,
"Joe",
"Bloggs",
"usrname",
"mygit",
"95555",
"Hello world!",
teacherRole,
"Backend Development",
cohort,
LocalDate.of(2025, 9, 8),
LocalDate.of(2026, 9, 8),
"fnwjkdnfj32.,."
));
} else {
teacherProfile = this.profileRepository.findById(2).orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Set;
import java.util.stream.Collectors;

//fixed issue with login.
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping
Expand Down Expand Up @@ -69,6 +70,17 @@ public ResponseEntity<?> registerUser(@Valid @RequestBody SignupRequest signupRe
if (userRepository.existsByEmail(signupRequest.getEmail())) {
return ResponseEntity.badRequest().body(new MessageResponse("Error: Email is already in use!"));
}


String emailRegex = "^\\w+([.-]?\\w+)*@\\w+([.-]?\\w+)*(\\.\\w{2,3})+$";
String passwordRegex = "^(?=.*[A-Z])(?=.*[0-9])(?=.*[#?!@$%^&-]).{8,}$";

if(!signupRequest.getEmail().matches(emailRegex))
return ResponseEntity.badRequest().body(new MessageResponse("Email is incorrectly formatted"));

if(!signupRequest.getPassword().matches(passwordRegex))
return ResponseEntity.badRequest().body(new MessageResponse("Password is incorrectly formatted"));

// Create a new user add salt here if using one
User user = new User(signupRequest.getEmail(), encoder.encode(signupRequest.getPassword()));
if (signupRequest.getCohort() != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.booleanuk.cohorts.controllers;

import com.booleanuk.cohorts.models.Cohort;
import com.booleanuk.cohorts.payload.response.CohortListResponse;
import com.booleanuk.cohorts.payload.response.CohortResponse;
import com.booleanuk.cohorts.payload.response.ErrorResponse;
import com.booleanuk.cohorts.payload.response.Response;
import com.booleanuk.cohorts.models.*;
import com.booleanuk.cohorts.payload.response.*;
import com.booleanuk.cohorts.repository.CohortRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand All @@ -28,7 +25,7 @@ public ResponseEntity<CohortListResponse> getAllCohorts() {
@GetMapping("{id}")
public ResponseEntity<Response> getCohortById(@PathVariable int id) {
Cohort cohort = this.cohortRepository.findById(id).orElse(null);
if (cohort == null) {
if (cohort == null || cohort.getUsers().isEmpty()) {
ErrorResponse error = new ErrorResponse();
error.set("not found");
return new ResponseEntity<>(error, HttpStatus.NOT_FOUND);
Expand Down
Loading