mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Фикс RequestAuthProvider
This commit is contained in:
parent
4828e8e895
commit
78f9fed6e1
1 changed files with 9 additions and 2 deletions
|
@ -12,15 +12,22 @@
|
|||
|
||||
public final class RequestAuthProvider extends AuthProvider {
|
||||
private String url;
|
||||
private Pattern response;
|
||||
private transient Pattern pattern;
|
||||
private String response;
|
||||
private boolean usePermission;
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
pattern = Pattern.compile(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthProviderResult auth(String login, String password, String ip) throws IOException {
|
||||
String currentResponse = IOHelper.request(new URL(getFormattedURL(login, password, ip)));
|
||||
|
||||
// Match username
|
||||
Matcher matcher = response.matcher(currentResponse);
|
||||
Matcher matcher = pattern.matcher(currentResponse);
|
||||
return matcher.matches() && matcher.groupCount() >= 1 ?
|
||||
new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.getLong(matcher.group("permission"))) : new ClientPermissions()) :
|
||||
authError(currentResponse);
|
||||
|
|
Loading…
Reference in a new issue