Skip to content
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

add registration function by spring security #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file added .metadata/.lock
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Binary file not shown.
3,022 changes: 3,022 additions & 0 deletions .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions .metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<typeInfoHistroy/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<qualifiedTypeNameHistroy/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>OFF</level> <!-- change to DEBUG to mimic '-consolelog' behaviour -->
</filter>
</appender>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${org.eclipse.m2e.log.dir}/0.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>${org.eclipse.m2e.log.dir}/%i.log</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>10</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>100MB</MaxFileSize>
</triggeringPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>

<appender name="EclipseLog" class="org.eclipse.m2e.logback.appender.EclipseLogAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>

<appender name="MavenConsoleLog" class="org.eclipse.m2e.logback.appender.MavenConsoleAppender">
</appender>

<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
<appender-ref ref="EclipseLog" />
<appender-ref ref="MavenConsoleLog" />
</root>

<logger name="com.ning.http.client" level="INFO" />
</configuration>
6 changes: 6 additions & 0 deletions .metadata/.plugins/org.eclipse.oomph.setup/workspace.setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<setup:Workspace
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:setup="http://www.eclipse.org/oomph/setup/1.0"
name="workspace"/>
3 changes: 3 additions & 0 deletions .metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Mar 10 11:21:31 ICT 2021
0.Icon=C\:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico
0.Path=C\:\\Program Files\\Git\\bin\\sh.exe
0.Translate=true
0.Args=--login -i
0.Name=Git Bash
11 changes: 11 additions & 0 deletions .metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="ChooseWorkspaceDialogSettings">
<item key="DIALOG_X_ORIGIN" value="380"/>
<item key="DIALOG_Y_ORIGIN" value="185"/>
</section>
<section name="WORKBENCH_SETTINGS">
<list key="ENABLED_TRANSFERS">
</list>
</section>
</section>
2 changes: 2 additions & 0 deletions .metadata/.plugins/org.eclipse.ui.intro/introstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<state reopen="false"/>
6 changes: 6 additions & 0 deletions .metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<workingSetManager>
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1615350098473_0" label="Java Main Sources" name="Java Main Sources"/>
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1615350098518_1" label="Java Test Sources" name="Java Test Sources"/>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1615350112195_2" label="Window Working Set" name="Aggregate for window 1615350112194"/>
</workingSetManager>
3 changes: 3 additions & 0 deletions .metadata/version.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Wed Mar 10 11:21:28 ICT 2021
org.eclipse.core.runtime=2
org.eclipse.platform=4.17.0.v20200902-1800
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ repositories {
}

dependencies {
// https://mvnrepository.com/artifact/javax.validation/validation-api
implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.18'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-validation'
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/aa/awesomecareer/controller/UsersController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.aa.awesomecareer.model.UserModel;
import com.aa.awesomecareer.service.UserService;
Expand Down Expand Up @@ -48,5 +53,23 @@ public String show(@PathVariable String email, Model model) {

return "users/show";
}

@GetMapping(value = { "/users/add", "/signup" })
public String add(Locale locale, Model model) {
model.addAttribute("user", new UserModel());
return "users/add";
}

@PostMapping(value = "/users")
public String create(@ModelAttribute("user") @Validated UserModel userModel, BindingResult bindingResult,
Model model, final RedirectAttributes redirectAttributes, HttpServletRequest request) throws Exception {
if (bindingResult.hasErrors()) {
logger.info("Returning register.jsp page, validate failed");
return "users/add";
}
userService.addUser(userModel);
// Add message to flash scope
return "redirect: " + request.getContextPath() + "/home";
}

}
32 changes: 32 additions & 0 deletions src/main/java/com/aa/awesomecareer/entity/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.aa.awesomecareer.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name = "application")
public class Application {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "userId")
private Integer userId;
@Column(name = "jobId")
private Integer jobId;

@ManyToOne
@JoinColumn(name = "id")
private User user;

@ManyToOne
@JoinColumn(name = "id")
private Job job;

}
34 changes: 34 additions & 0 deletions src/main/java/com/aa/awesomecareer/entity/Bookmark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.aa.awesomecareer.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name = "bookmark")
public class Bookmark {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;

@Column(name = "userId")
private Integer userId;
@Column(name = "jobId")
private Integer jobId;

@ManyToOne
@JoinColumn(name = "id")
private User user;

@ManyToOne
@JoinColumn(name = "id")
private Job job;


}
35 changes: 35 additions & 0 deletions src/main/java/com/aa/awesomecareer/entity/Certificate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.aa.awesomecareer.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@SuppressWarnings("serial")
@Entity
@Table(name = "certificate")
public class Certificate {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "userId",length = 256)
private Integer userId;
@Column(name = "title",length = 256)
private String title;
@Column(name = "issuedTime")
@Temporal(value = TemporalType.TIMESTAMP)
private Date issuedTime;

@ManyToOne
@JoinColumn(name = "id")
private User user;

}
44 changes: 44 additions & 0 deletions src/main/java/com/aa/awesomecareer/entity/Company.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.aa.awesomecareer.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@SuppressWarnings("serial")
@Entity
@Table(name="company")
public class Company {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;

@Column(name="name", length=256)
private String name;
@Column(name="address", length=256)
private String address;
@Column(name="website", length=256)
private String website;
@Column(name="foundedTime")
@Temporal(value=TemporalType.TIMESTAMP)
private Date foundedTime;
@Column(name="foundedBy", length=256)
private String foundedBy;
@Column(name="memberTotal")
private Integer memberTotal;
@Column(name="image", length=256)
private String image;

@OneToMany(mappedBy = "follow")
private List<Follow> follows;


}
38 changes: 38 additions & 0 deletions src/main/java/com/aa/awesomecareer/entity/Education.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.aa.awesomecareer.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@SuppressWarnings("serial")
@Entity
@Table(name = "education")
public class Education {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;

@Column(name = "school", length = 256)
private String school;
@Column(name = "major", length = 256)
private String major;
@Column(name = "description", length = 3000)
private String description;
@Column(name = "graduation")
@Temporal(value = TemporalType.TIMESTAMP)
private Date graduation;

@ManyToOne
@JoinColumn(name = "id")
private User user;

}
32 changes: 32 additions & 0 deletions src/main/java/com/aa/awesomecareer/entity/Experience.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.aa.awesomecareer.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@SuppressWarnings("serial")
@Entity
@Table(name = "experience")
public class Experience {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;

@Column(name = "companyName", length = 256)
private String companyName;
@Column(name = "jobTitle", length = 256)
private String jobTitle;
@Column(name = "startTime")
@Temporal(value = TemporalType.TIMESTAMP)
private String startTime;
@Column(name = "endTime")
@Temporal(value = TemporalType.TIMESTAMP)
private String endTime;
@Column(name = "description", length = 3000)
private String description;
}
Loading