Skip to content

Commit 6edaf50

Browse files
authored
fix: delete by slash all characters in username during authorization … (#110)
* fix: delete by slash all characters in username during authorization to support github's user names. * delete github prefix from user name
1 parent f0fda62 commit 6edaf50

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/main/java/com/artipie/front/ui/PostSignIn.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,23 @@ private void receiveToken(final Request req, final Response rsp) {
6969
req.queryParamOrDefault("password", "")
7070
);
7171
req.session().attribute("token", token);
72-
req.session().attribute("uid", req.queryParamOrDefault("username", ""));
72+
req.session().attribute("uid", deleteGithubPrefix(req.queryParamOrDefault("username", "")));
7373
rsp.redirect("/dashboard");
7474
}
75+
76+
/**
77+
* Delete github prefix from user name.
78+
* @param username User name.
79+
* @return User name without github prefix.
80+
*/
81+
private static String deleteGithubPrefix(final String username) {
82+
final String prefix = "github.com/";
83+
final String result;
84+
if (username.startsWith(prefix)) {
85+
result = username.substring(prefix.length());
86+
} else {
87+
result = username;
88+
}
89+
return result;
90+
}
7591
}

0 commit comments

Comments
 (0)