Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 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
1091f04
Class diagram
emazau Sep 10, 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
c85230d
added get cohorts to cohortsController
fanden Sep 15, 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
dfd1960
Added Endpoint for courses
Sep 16, 2025
9658d96
Merge pull request #33 from boolean-uk/27-api---endpoint-course
Richard-Persson Sep 16, 2025
f5809a8
small update
fanden Sep 16, 2025
c65247e
added get cohorts to cohortsController
fanden Sep 15, 2025
63a20f2
small update
fanden 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
c4a8d2d
added delete in userController, fixed mappings in models to ensure ca…
magnusgit1 Sep 16, 2025
b7f61fd
Fixed hard coded postst and posts
Sep 16, 2025
191d91f
Merge branch 'main' into fixed-hardcoded-posts
emazau Sep 16, 2025
e890269
Merge pull request #34 from boolean-uk/31-api---patch---endpoint-student
emazau Sep 16, 2025
786b40d
Merge pull request #37 from boolean-uk/fixed-hardcoded-posts
emazau Sep 16, 2025
c2bd63a
working
fanden Sep 16, 2025
d47a65c
working
fanden Sep 16, 2025
5f23464
added getmappings to retrieve profiles
magnusgit1 Sep 16, 2025
e5140b1
changed cohort to contain profiles and not users
Richard-Persson Sep 16, 2025
ef0596f
Merge pull request #42 from boolean-uk/fix_Cohort
Richard-Persson Sep 16, 2025
86d501d
Merge branch 'main' into FIX/make-users-and-profiles-deletable
Richard-Persson Sep 16, 2025
fd2961c
Merge pull request #38 from boolean-uk/FIX/make-users-and-profiles-de…
Richard-Persson Sep 16, 2025
3cefb15
Merge pull request #41 from boolean-uk/API/getmapping-for-profile-con…
Richard-Persson Sep 16, 2025
ca8c475
Made the posts to work
Sep 16, 2025
130ca1b
Merge pull request #40 from boolean-uk/9-api---get---cohorts-endpoint…
Richard-Persson Sep 16, 2025
c042724
Merge pull request #44 from boolean-uk/POSTS-made-it-work
emazau Sep 16, 2025
f63ecdd
Merge pull request #15 from boolean-uk/classdiagram
emazau Sep 16, 2025
d8f2dfa
remove postrequest
Sep 16, 2025
1020d0f
first
magnusgit1 Sep 16, 2025
737d823
fixed bio length in profile
magnusgit1 Sep 17, 2025
1f2cba2
Added student to a Cohort
Sep 17, 2025
5c9e92d
added comments, posts and likedposts to user and fixed json-loops
magnusgit1 Sep 17, 2025
e392411
added search endoint for profiles
fanden Sep 17, 2025
571fdc5
Added get students
Sep 17, 2025
140ceef
added templates
magnusgit1 Sep 17, 2025
c67f402
added md bodies
magnusgit1 Sep 17, 2025
68dd4a3
Merge pull request #56 from boolean-uk/36-api---search
fanden Sep 17, 2025
36db025
added deletemapping to postController
magnusgit1 Sep 17, 2025
031d071
Added patch for teachers editing student profiles
Richard-Persson Sep 17, 2025
e39fda1
added patchmapping
magnusgit1 Sep 17, 2025
08f3d8c
I created it so that name and lastname gets from the token when loggi…
Sep 17, 2025
18b6739
Merge pull request #49 from boolean-uk/API/make-bio-length-300-in-pro…
emazau Sep 17, 2025
96e993c
Merge pull request #51 from boolean-uk/45-api---post---add-student-to…
emazau Sep 17, 2025
5420fd1
Merge pull request #52 from boolean-uk/API/add-one-to-many-relation-i…
emazau Sep 17, 2025
e192475
Merge pull request #58 from boolean-uk/53-api---get---all-students
emazau Sep 17, 2025
1088796
Merge pull request #59 from boolean-uk/FEAT/issue-templates
emazau Sep 17, 2025
437d7bd
Merge pull request #61 from boolean-uk/API/add-deletemapping-to-postc…
emazau Sep 17, 2025
5b09941
Merge pull request #62 from boolean-uk/50-api---patch---teacher-updat…
emazau Sep 17, 2025
d5feb02
Added new endpoint and nullpointexception
Sep 17, 2025
927ec79
Merge pull request #64 from boolean-uk/FEAT/add-patchmapping-in-userc…
emazau Sep 17, 2025
a364f6f
Merge pull request #65 from boolean-uk/sorry-wrong-format
emazau Sep 17, 2025
1b9147f
Merge branch 'main' into 53-api---get---all-students
Isabelltran Sep 17, 2025
e5e653c
Merge pull request #66 from boolean-uk/53-api---get---all-students
emazau Sep 17, 2025
e9b1814
added Cohort Request
Sep 17, 2025
23cc06f
Fix merge bugs
Sep 17, 2025
7efe5a4
fixed bugs merge
Sep 17, 2025
8019cfb
Creating gradle build script
fanden Sep 17, 2025
6c81d2a
Update gradle.yml
fanden Sep 17, 2025
d4795b0
Update gradle.yml
fanden Sep 17, 2025
0468014
Update gradle.yml
fanden Sep 17, 2025
97eb648
removed template yml
magnusgit1 Sep 18, 2025
97d513e
fixed .md-files
magnusgit1 Sep 18, 2025
ba4d5cf
added start_date and end_date, started on edit Course
Sep 18, 2025
973541f
fix jsonignore loops
Sep 18, 2025
2977a05
Added GET all teachers
Sep 18, 2025
5185932
Merge pull request #67 from boolean-uk/54-api---get---all-teachers
Richard-Persson Sep 18, 2025
d61f858
fixed infinite loops again
Sep 18, 2025
dcd0a1c
Merge branch 'main' of https://github.com/boolean-uk/java-team-dev-se…
Sep 18, 2025
519cea9
Added Get teachers by Cohort ID
Sep 18, 2025
cb3155e
Merge branch 'main' into 60-api---get---all-teacher-in-cohort
Isabelltran Sep 18, 2025
d8cc0ae
Fixed so fields that are not included are overwritten with null
Sep 18, 2025
db9dba3
Merge pull request #72 from boolean-uk/71-fix-preserve-existing-value…
Richard-Persson Sep 18, 2025
a28e298
added note model, controller, repo and request
Richard-Persson Sep 18, 2025
03cb7f1
Fixed bugs and added unique email
Sep 18, 2025
4a261aa
Merge pull request #73 from boolean-uk/71-fix-preserve-existing-value…
Richard-Persson Sep 18, 2025
d06fe5a
added new classes
fanden Sep 18, 2025
c13dfec
Merge branch 'main' of github.com:boolean-uk/java-team-dev-server-250…
fanden Sep 18, 2025
62a614f
added patch to cohortController
magnusgit1 Sep 18, 2025
d7692e5
Updated post to actually save to the repository
Richard-Persson Sep 18, 2025
ad92a4e
Merge branch 'main' into 47-api---patch---edit-cohort
magnusgit1 Sep 18, 2025
221e9e1
Merge branch '69-api---notes' of github.com:boolean-uk/java-team-dev-…
Richard-Persson Sep 18, 2025
df382aa
Got an example test working
fanden Sep 18, 2025
f04fb7a
fixed brackets
magnusgit1 Sep 18, 2025
7e44f2b
Merge pull request #68 from boolean-uk/60-api---get---all-teacher-in-…
Richard-Persson Sep 18, 2025
5a1d044
Merge pull request #75 from boolean-uk/69-api---notes
emazau Sep 18, 2025
1a11bdc
Merge pull request #74 from boolean-uk/47-api---patch---edit-cohort
Richard-Persson Sep 18, 2025
86f4bc9
minor fix in user/profile
Richard-Persson Sep 18, 2025
3cc2fe4
Merge pull request #76 from boolean-uk/minor_fix_to_user_profile_role
emazau Sep 18, 2025
f170584
New features to posts pages
Sep 18, 2025
8597f1f
Merge pull request #77 from boolean-uk/Posts-pages-new-features
emazau Sep 18, 2025
ed2d1fc
Added user role to token
Sep 19, 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
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: "🐞 Bug Fix"
about: "Report a bug or something that is not working as expected"
title: "[FIX] "
labels: bug
assignees: ""
---

## 🐛 Bug Description
A clear and concise description of what the bug is.

## 🔄 Steps to Reproduce
Steps to reproduce the behavior:
1. Go to ...
2. Click on ...
3. See error ...

## ✅ Expected Behavior
What should have happened instead?

## 📸 Screenshots / Logs
If applicable, add screenshots or error messages.

## 🖥️ Environment
- OS:
- Version:
- Other relevant info:
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: "✨ Feature Request"
about: "Suggest a new feature or improvement"
title: "[FEATURE] "
labels: enhancement
assignees: ""
---

## ✨ Description
What would you like to add or improve?

## 🎯 Use Case
Why is this useful? Who benefits from it?

## 💡 Proposed Solution
How could this be implemented? (optional)

## 📎 Additional Info
Anything else you’d like to share? (related issues, links, references, etc.)
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: "📌 Other"
about: "Questions, discussions, or anything else"
title: "[OTHER] "
labels: question
assignees: ""
---

## 📌 Description
What is this about?

## 🌍 Context
Why is this relevant?

## 📎 Additional Info
Anything else that might be useful.
43 changes: 43 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle Wrapper
run: ./gradlew build --exclude-task test

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: Package
path: build/libs
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ out/
### VS Code ###
.vscode/

### Project specific
application.yml
build
.DS_Store
application-azuread.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-----
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ dependencies {
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// https://mvnrepository.com/artifact/org.springframework/spring-test
testImplementation 'org.springframework:spring-test'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation 'org.junit.jupiter:junit-jupiter-api'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine
testImplementation 'org.junit.jupiter:junit-jupiter-engine'


// https://mvnrepository.com/artifact/jakarta.validation/jakarta.validation-api
implementation 'jakarta.validation:jakarta.validation-api:3.1.1'
}
Expand Down
Binary file added image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 8 additions & 44 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 All @@ -32,6 +33,13 @@ public static void main(String[] args) {

@Override
public void run(String... args) {
// Create a cohort.
Cohort cohort;
if (!this.cohortRepository.existsById(1)) {
cohort = this.cohortRepository.save(new Cohort());
} else {
cohort = this.cohortRepository.findById(1).orElse(null);
}
Role teacherRole;
if (!this.roleRepository.existsByName(ERole.ROLE_TEACHER)) {
teacherRole = this.roleRepository.save(new Role(ERole.ROLE_TEACHER));
Expand All @@ -51,49 +59,5 @@ public void run(String... args) {
if (!this.roleRepository.existsByName(ERole.ROLE_ADMIN)) {
this.roleRepository.save(new Role(ERole.ROLE_ADMIN));
}
// Create a cohort.
Cohort cohort;
if (!this.cohortRepository.existsById(1)) {
cohort = this.cohortRepository.save(new Cohort());
} else {
cohort = this.cohortRepository.findById(1).orElse(null);
}
// Create some users
User studentUser;
if (!this.userRepository.existsById(1)) {
studentUser = new User("[email protected]", this.encoder.encode("Testpassword1!"), cohort);
studentUser.setRoles(studentRoles);
studentUser = this.userRepository.save(studentUser);
} else {
studentUser = this.userRepository.findById(1).orElse(null);
}
Profile studentProfile;
if (!this.profileRepository.existsById(1)) {
studentProfile = this.profileRepository.save(new Profile(studentUser, "Joe", "Bloggs", "Hello world!", "student1"));
} else {
studentProfile = this.profileRepository.findById(1).orElse(null);
}

User teacherUser;
if (!this.userRepository.existsById(2)) {
teacherUser = new User("[email protected]", this.encoder.encode("password"));
teacherUser.setRoles(teacherRoles);
teacherUser = this.userRepository.save(teacherUser);
} else {
teacherUser = this.userRepository.findById(2).orElse(null);
}
Profile teacherProfile;
if (!this.profileRepository.existsById(2)) {
teacherProfile = this.profileRepository.save(new Profile(teacherUser, "Rick", "Sanchez", "Hello there!", "teacher1"));
} else {
teacherProfile = this.profileRepository.findById(2).orElse(null);
}

if (!this.postRepository.existsById(1)) {
this.postRepository.save(new Post(studentUser, "My first post!"));
}
if (!this.postRepository.existsById(2)) {
this.postRepository.save(new Post(teacherUser, "Hello, students!"));
}
}
}
44 changes: 31 additions & 13 deletions src/main/java/com/booleanuk/cohorts/controllers/AuthController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
package com.booleanuk.cohorts.controllers;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.booleanuk.cohorts.models.ERole;
import com.booleanuk.cohorts.models.Role;
import com.booleanuk.cohorts.models.User;
Expand All @@ -12,21 +30,10 @@
import com.booleanuk.cohorts.repository.UserRepository;
import com.booleanuk.cohorts.security.jwt.JwtUtils;
import com.booleanuk.cohorts.security.services.UserDetailsImpl;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import jakarta.validation.Valid;

//fixed issue with login.
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping
Expand Down Expand Up @@ -69,6 +76,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
Loading