aboutsummaryrefslogtreecommitdiff
path: root/juick-commands/src/main/java/com/juick/command/Login.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-commands/src/main/java/com/juick/command/Login.java')
-rw-r--r--juick-commands/src/main/java/com/juick/command/Login.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/juick-commands/src/main/java/com/juick/command/Login.java b/juick-commands/src/main/java/com/juick/command/Login.java
new file mode 100644
index 00000000..0dc6a021
--- /dev/null
+++ b/juick-commands/src/main/java/com/juick/command/Login.java
@@ -0,0 +1,42 @@
+package com.juick.command;
+
+import com.juick.User;
+import com.juick.server.protocol.ProtocolListener;
+import com.juick.service.UserService;
+import lombok.Getter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author ma1uta
+ */
+@Component
+@Getter
+public class Login implements Command {
+
+ private static final Pattern PATTERN = Pattern.compile("^login$", Pattern.CASE_INSENSITIVE);
+
+ private final UserService userService;
+
+ @Autowired
+ public Login(UserService userService) {
+ this.userService = userService;
+ }
+
+ @Override
+ public Pattern pattern() {
+ return PATTERN;
+ }
+
+ @Override
+ public String help() {
+ return "LOGIN - log in to Juick website";
+ }
+
+ @Override
+ public String execute(User sender, ProtocolListener protocolListener, String command) {
+ return "http://juick.com/login?hash=" + getUserService().getHashByUID(sender.getUid());
+ }
+}