Skip to content
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
8 changes: 0 additions & 8 deletions resources/view/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ <h3 class="mb-3">Sign in</h3>
type="button">
<i class="fa-brands fa-google"></i>
</a>
<a class="btn btn-primary btn-lg me-2" href="/oauth2/authorization/vk" style="padding-left: 17px; padding-right: 17px;"
type="button">
<i class="fa-brands fa-vk"></i>
</a>
<a class="btn btn-danger btn-lg me-2" href="/oauth2/authorization/yandex" style="padding-left: 21px; padding-right: 21px;"
type="button">
<i class="fa-brands fa-yandex"></i>
</a>
<a class="btn btn-dark btn-lg me-2" href="/oauth2/authorization/github" type="button">
<i class="fa-brands fa-github"></i>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,34 @@
import org.springframework.core.io.UrlResource;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileOutputStream;

import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;



@UtilityClass
public class FileUtil {
private static final String ATTACHMENT_PATH = "./attachments/%s/";

public static void upload(MultipartFile multipartFile, String directoryPath, String fileName) {

if (multipartFile.isEmpty()) {
throw new IllegalRequestDataException("Select a file to upload.");
}

File dir = new File(directoryPath);
if (dir.exists() || dir.mkdirs()) {
File file = new File(directoryPath + fileName);
try (OutputStream outStream = new FileOutputStream(file)) {
outStream.write(multipartFile.getBytes());
} catch (IOException ex) {
throw new IllegalRequestDataException("Failed to upload file" + multipartFile.getOriginalFilename());
}
try {
Path dirPath = Paths.get(directoryPath);
Files.createDirectories(dirPath);
Path filePath = dirPath.resolve(fileName);
Files.write(filePath, multipartFile.getBytes());
} catch (IOException e) {
throw new IllegalRequestDataException("Failed to upload file" + multipartFile.getOriginalFilename());
}

}

public static Resource download(String fileLink) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/javarush/jira/login/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@
public class User extends TimestampEntry implements HasIdAndEmail, Serializable {
@Serial
private static final long serialVersionUID = 1L;

@NoHtml
@Size(max = 32)
@Nullable
@Column(name = "display_name", nullable = false, unique = true)
String displayName;

@Column(name = "email", nullable = false, unique = true)
@Email
@NotBlank
@Size(max = 128)
@NoHtml // https://stackoverflow.com/questions/17480809
private String email;

@Column(name = "password")
@NotBlank(groups = {View.OnCreate.class})
@Size(min = 5, max = 128, groups = {View.OnCreate.class})
Expand All @@ -55,16 +58,19 @@ public class User extends TimestampEntry implements HasIdAndEmail, Serializable
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonView(View.OnCreate.class)
private String password;

@NotBlank
@Size(min = 2, max = 32)
@NoHtml
@Column(name = "first_name", nullable = false)
private String firstName;

@Size(max = 32)
@NoHtml
@Column(name = "last_name")
@Nullable
private String lastName;

@CollectionTable(name = "user_role",
joinColumns = @JoinColumn(name = "user_id"),
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "role"}, name = "uk_user_role"))
Expand Down

This file was deleted.

This file was deleted.

44 changes: 10 additions & 34 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ spring:
jdbc.batch_size: 20
datasource:
url: jdbc:postgresql://localhost:5432/jira
username: jira
password: JiraRush
username: ${DB_USER:jira}
password: ${DB_PASSWORD:JiraRush}

liquibase:
changeLog: "classpath:db/changelog.sql"
Expand All @@ -51,48 +51,24 @@ spring:
client:
registration:
github:
client-id: 3d0d8738e65881fff266
client-secret: 0f97031ce6178b7dfb67a6af587f37e222a16120
client-id: ${GITHUB_ID:3d0d8738e65881fff266}
client-secret: ${GITHUB_CLIENT_SECRET:0f97031ce6178b7dfb67a6af587f37e222a16120}
scope:
- email
google:
client-id: 329113642700-f8if6pu68j2repq3ef6umd5jgiliup60.apps.googleusercontent.com
client-secret: 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
client-id: ${GOOGLE_CLIENT_ID:329113642700-f8if6pu68j2repq3ef6umd5jgiliup60.apps.googleusercontent.com}
client-secret: ${GOOGLE_CLIENT_SECRET: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}
scope:
- email
- profile
vk:
client-id: 51562377
client-secret: jNM1YHQy1362Mqs49wUN
client-name: Vkontakte
redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
client-authentication-method: client_secret_post
authorization-grant-type: authorization_code
scope: email
yandex:
client-id: 2f3395214ba84075956b76a34b231985
client-secret: ed236c501e444a609b0f419e5e88f1e1
client-name: Yandex
redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
authorization-grant-type: authorization_code
gitlab:
client-id: b8520a3266089063c0d8261cce36971defa513f5ffd9f9b7a3d16728fc83a494
client-secret: e72c65320cf9d6495984a37b0f9cc03ec46be0bb6f071feaebbfe75168117004
client-id: ${GITLAB_CLIENT_ID:b8520a3266089063c0d8261cce36971defa513f5ffd9f9b7a3d16728fc83a494}
client-secret: ${GITLAB_CLIENT_SECRET:e72c65320cf9d6495984a37b0f9cc03ec46be0bb6f071feaebbfe75168117004}
client-name: GitLab
redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
authorization-grant-type: authorization_code
scope: read_user
provider:
vk:
authorization-uri: https://oauth.vk.com/authorize
token-uri: https://oauth.vk.com/access_token
user-info-uri: https://api.vk.com/method/users.get?v=8.1
user-name-attribute: response
yandex:
authorization-uri: https://oauth.yandex.ru/authorize
token-uri: https://oauth.yandex.ru/token
user-info-uri: https://login.yandex.ru/info
user-name-attribute: login
gitlab:
authorization-uri: https://gitlab.com/oauth/authorize
token-uri: https://gitlab.com/oauth/token
Expand All @@ -111,8 +87,8 @@ spring:
enable: true
auth: true
host: smtp.gmail.com
username: jira4jr@gmail.com
password: zdfzsrqvgimldzyj
username: ${MAIL_USERNAME:jira4jr@gmail.com}
password: ${MAIL_PASSWORD:zdfzsrqvgimldzyj}
port: 587
thymeleaf.check-template-location: false

Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/application-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ spring:
mode: always
datasource:
url: jdbc:postgresql://localhost:5433/jira-test
username: jira
password: JiraRush
username: ${TEST_DB_USER:jira}
password: ${TEST_DB_PASSWORD:JiraRush}