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
18 changes: 18 additions & 0 deletions src/main/java/easytests/auth/controllers/AuthController.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package easytests.auth.controllers;

import easytests.auth.helpers.SessionLoginStoreHelper;
import easytests.config.LocalizationConfig;
import javax.servlet.http.HttpServletRequest;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -10,13 +12,29 @@

/**
* @author malinink
* @author Loriens
*/
@Controller
@RequestMapping("/auth")
public class AuthController {

private final LocalizationConfig localization = new LocalizationConfig();

@GetMapping("/sign-in")
public String signIn(Model model, HttpServletRequest request) {
final ReloadableResourceBundleMessageSource msg = localization.messageSource();
final String enterEmail = new String("enter_email");
final String enterPassword = new String("enter_password");
final String forgotPassword = new String("forgot_password");
final String loginText = new String("login_text");
final String language = new String("sign-in_ru");

model.addAttribute("login", new SessionLoginStoreHelper(request.getSession(false)).getLogin());
model.addAttribute("sign_in", msg.getMessage("text", null, language, null));
model.addAttribute(enterEmail, msg.getMessage(enterEmail, null, language, null));
model.addAttribute(enterPassword, msg.getMessage(enterPassword, null, language, null));
model.addAttribute(forgotPassword, msg.getMessage(forgotPassword, null, language, null));
model.addAttribute(loginText, msg.getMessage(loginText, null, language, null));
return "auth/sign-in";
}
}
21 changes: 21 additions & 0 deletions src/main/java/easytests/config/LocalizationConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package easytests.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

/**
* @author Loriens
*/
@Configuration
public class LocalizationConfig {

@Bean
public ReloadableResourceBundleMessageSource messageSource() {
final ReloadableResourceBundleMessageSource resourseBundle = new
ReloadableResourceBundleMessageSource();
resourseBundle.setBasename("classpath:/locales/sign-in");
resourseBundle.setDefaultEncoding("UTF-8");
return resourseBundle;
}
}
5 changes: 5 additions & 0 deletions src/main/resources/locales/sign-in_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
text=Sign In
enter_email=Enter your email
enter_password=Enter your password
forgot_password=Forgot Password?
login_text=Login
5 changes: 5 additions & 0 deletions src/main/resources/locales/sign-in_ru.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
text=Войдите
enter_email=Введите ваш емейл
enter_password=Введите ваш пароль
forgot_password=Забыли пароль?
login_text=Войти
10 changes: 5 additions & 5 deletions src/main/resources/templates/auth/sign-in.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ content: contents {
div(class :'center-align') {
div (class:'section') {
h5 {
span ('Sign In')
span (sign_in)
}
}
div (class:'container') {
Expand All @@ -22,7 +22,7 @@ content: contents {
}
input (class:'validate', type:'email', name:'login', id:'login', required:'', value:login)
label (for:'email') {
span ('Enter your email')
span (enter_email)
}
}
}
Expand All @@ -33,20 +33,20 @@ content: contents {
}
input (class:'validate', type:'password', name:'password', id:'password', required:'')
label (for:'password') {
span ('Enter your password')
span (enter_password)
}
}
label (style:'float: right;') {
a (class: 'grey-text', href:'#!') {
b ('Forgot Password?')
b (forgot_password)
}
}
}
br
div(class :'center-align') {
div (class:'row') {
button (type:'submit', name:'btn_login', class:'col s12 btn btn-large waves-effect waves-light teal lighten-2') {
span ('Login')
span (login_text)
}
}
}
Expand Down