各种细节打磨优化,增加提示

This commit is contained in:
暮光:城中城
2019-02-02 21:17:44 +08:00
committed by zhanghongli
parent 15cfa7e2d1
commit e96418e346
13 changed files with 112 additions and 63 deletions

View File

@@ -22,6 +22,8 @@ import org.springframework.security.web.authentication.rememberme.RememberMeAuth
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
import org.springframework.util.DigestUtils;
import java.util.Objects;
@Order(1)
@Configuration
@EnableWebSecurity
@@ -98,7 +100,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public boolean matches(CharSequence charSequence, String s) {
String digestAsHex = DigestUtils.md5DigestAsHex(charSequence.toString().getBytes());
return s.equals(digestAsHex);
return Objects.equals(s, digestAsHex);
}
}).and().authenticationProvider(rememberMeAuthenticationProvider());
}

View File

@@ -16,23 +16,22 @@
<div class="heading divider primary-pale">
<div class="title">登录 <span class="reason"> 您没有权限访问该内容或需要登录</span></div>
</div>
<div class="content box">
<div class="control has-label-left"><!-- has-error -->
<input type="text" name="username" class="input" v-model="userId" placeholder="用户名">
<label for="account"><i class="icon-user"></i></label>
<div class="help-text" v-if="errorInfo.length > 0">{{errorInfo}}</div>
<input type="text" name="username" class="input enter-input" v-model="userId" placeholder="用户名">
<label><i class="icon-user"></i></label>
<div class="help-text red-txt" v-if="userNameError.length > 0">{{userNameError}}</div>
</div>
<div class="control has-label-left">
<input type="password" name="password" v-model="password" class="input" placeholder="密码">
<input type="password" name="password" v-model="password" class="input enter-input" placeholder="密码">
<input type="hidden" name="validateCode" value="1234">
<label for="account"><i class="icon-key"></i></label>
<label><i class="icon-key"></i></label>
<div class="help-text red-txt" v-if="passwordError.length > 0">{{passwordError}}</div>
</div>
<div class="control">
<button type="submit" v-on:click="loginSubmit" class="btn block primary">登录</button>
</div>
</div>
</div>
</div>
</div>
@@ -42,6 +41,7 @@
<script src="../lib/mzui/js/mzui.min.js"></script>
<script src="../lib/vue/vue.js"></script>
<script src="../lib/mg/js/common.js"></script>
<script src="../lib/mg/js/toast.js"></script>
<script>
var app = new Vue({
@@ -49,7 +49,11 @@
data: {
userId: "",
password: "",
errorInfo: ""
userNameError: "",
passwordError: ""
},
mounted: function(){
this.init();
},
methods: {
loginSubmit: function() {
@@ -58,12 +62,29 @@
password: app.password,
validateCode: "1234"
};
post(ctx + "login", param, function(result) {
app.userNameError = "";
app.passwordError = "";
if(app.userId == "") {
app.userNameError = "用户名不能为空";
return;
}
if(app.password == "") {
app.passwordError = "密码不能为空";
return;
}
post(ctx + "login", param, function (result) {
console.log(result);
if(result.errCode == 200) {
if (result.errCode == 200) {
location.href = result.data;
} else {
alert("登录失败," + result.errMsg);
app.passwordError = "登录失败," + result.errMsg;
}
});
},
init: function () {
$(".enter-input").keyup(function (e) {
if (e.keyCode == 13) {
app.loginSubmit();
}
});
}
@@ -73,6 +94,7 @@
<style>
.reason{color: #f00;font-size: 12px;}
.red-txt{color: #f00;}
</style>
</html>