Updated student html and made the creation date mandatory for basic entity.

This commit is contained in:
Andrew Lalis 2019-06-03 10:08:49 +02:00 committed by andrewlalis
parent 241a57b282
commit 70df5c74ea
4 changed files with 23 additions and 17 deletions

View File

@ -51,8 +51,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.and()
.authorizeRequests() // Only logged in users should be able to see site content.
.antMatchers("/**").authenticated()
.anyRequest().authenticated()
.antMatchers("/**").hasRole("user")
.anyRequest().hasRole("user")
.and()
.formLogin()
@ -72,6 +72,10 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.deleteCookies("JSESSIONID");
}
/**
* Configures Spring Security to use a specific password encoder.
* @return The password encoder to use.
*/
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();

View File

@ -38,7 +38,7 @@ public abstract class BasicEntity {
value = TemporalType.TIMESTAMP
)
@CreationTimestamp
@Column
@Column(nullable = false)
private Date createdOn;
protected BasicEntity() {}

View File

@ -7,6 +7,9 @@ import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* A custom user details service to supply database persistent user information to Spring Security.
*/
@Service
public class UserDetailsService implements org.springframework.security.core.userdetails.UserDetailsService {

View File

@ -6,28 +6,27 @@
<div class="row">
<div class="col">
<p>
Here you can register to create a new account to access the information provided by this application, whether you are a professor, teaching assistant, or student. After filling out this submission form, you'll receive an email with a link to verify that you are who you say you are, after which your account will be activated.
To register as a student, please fill out the form below. Make sure to double-check that all information is entered is accurate.
</p>
<p>
Where the form asks for a <em>Registration Code</em>, please provide the code that has been given to you by your lecturers. This code ensures that you'll join the right course.
</p>
</div>
</div>
<div class="row justify-content-center">
<h3>I am a ...</h3>
<div class="col">
<form action="/register/student" method="post" enctype="application/x-www-form-urlencoded">
<div class="form-group">
<label>
Registration Code:
<input type="text" name="registration_code" class="form-control">
</label>
</div>
<div class="row justify-content-center">
<div class="col text-center">
<a class="btn btn-primary" th:href="@{/register/student}">Student</a>
</div>
<div class="col text-center">
<a class="btn btn-primary" th:href="@{/register/teaching_assistant}">Teaching Assistant</a>
</div>
<div class="col text-center">
<a class="btn btn-primary" th:href="@{/register/administrator}">Administrator</a>
</form>
</div>
</div>
</section>
</body>