aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model/User.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-11-18 18:08:52 +0500
committerAbyss777 <abyss@fox5.ru>2016-11-18 18:08:52 +0500
commit670c8c7041163a2232d3edb4ef413af70182ea0a (patch)
treeb18b1aa0b18709d1b75aa3f78c69264daca7f060 /src/org/traccar/model/User.java
parentc9b67d19132b687bea9130f39f13a5515b120e5e (diff)
downloadtrackermap-server-670c8c7041163a2232d3edb4ef413af70182ea0a.tar.gz
trackermap-server-670c8c7041163a2232d3edb4ef413af70182ea0a.tar.bz2
trackermap-server-670c8c7041163a2232d3edb4ef413af70182ea0a.zip
- Flip user-token map
- Fix null check - Combine validation to setter
Diffstat (limited to 'src/org/traccar/model/User.java')
-rw-r--r--src/org/traccar/model/User.java14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java
index 816f49da9..e6b9d663f 100644
--- a/src/org/traccar/model/User.java
+++ b/src/org/traccar/model/User.java
@@ -188,23 +188,15 @@ public class User extends Extensible {
public void setToken(String token) {
if (token != null && !token.isEmpty()) {
- if (validateToken(token)) {
- this.token = token;
- } else {
- throw new IllegalArgumentException("Bad token");
+ if (!token.matches("^[a-zA-Z0-9]{16,}$")) {
+ throw new IllegalArgumentException("Illegal token");
}
+ this.token = token;
} else {
this.token = null;
}
}
- public static boolean validateToken(String token) {
- if (token.length() < 16 || !token.matches("^[a-zA-Z0-9]+$")) {
- return false;
- }
- return true;
- }
-
public String getPassword() {
return null;
}