- Map<String, String> post = new HashMap<String, String>();
- post.put("LoginForm[sfLoginUsername]",
- Instance.getConfig().getString(Config.LOGIN_YIFFSTAR_USER));
- post.put("LoginForm[sfLoginPassword]",
- Instance.getConfig().getString(Config.LOGIN_YIFFSTAR_PASS));
- post.put("YII_CSRF_TOKEN", "");
-
- // Cookies will actually be retained by the cache manager once logged in
- // TODO: not working yet, once fixed can be removed (adding "/guest" to
- // URLs fix the access problem!):
- /*
- * Instance.getCache() .openNoCache(new
- * URL("https://www.sofurry.com/user/login"), this, post).close();
- */
+ // Note: this should not be necessary anymore
+ // (the "/guest" trick is enough)
+ String login = Instance.getInstance().getConfig().getString(Config.LOGIN_YIFFSTAR_USER);
+ String password = Instance.getInstance().getConfig().getString(Config.LOGIN_YIFFSTAR_PASS);
+
+ if (login != null && !login.isEmpty() && password != null
+ && !password.isEmpty()) {
+
+ Map<String, String> post = new HashMap<String, String>();
+ post.put("LoginForm[sfLoginUsername]", login);
+ post.put("LoginForm[sfLoginPassword]", password);
+ post.put("YII_CSRF_TOKEN", "");
+ post.put("yt1", "Login");
+ post.put("returnUrl", "/");
+
+ // Cookies will actually be retained by the cache manager once
+ // logged in
+ Instance.getInstance().getCache()
+ .openNoCache(new URL("https://www.sofurry.com/user/login"), this, post, null, null).close();
+ }