Skip to content

Commit

Permalink
Fix logic to check login status
Browse files Browse the repository at this point in the history
Signed-off-by: Kotaro Inoue <k.musaino@gmail.com>
  • Loading branch information
musaprg committed Jul 21, 2023
1 parent d1b659e commit 38088d4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions librarejob/rarejob.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,16 @@ func (c *client) Login(ctx context.Context, username, password string) error {

if err := c.wd.Wait(func(wd selenium.WebDriver) (bool, error) {
zap.L().Debug("checking if the login has been completed", zap.String("url", c.getCurrentURL()))
_, err := c.wd.GetCookie("PHPSESSID")
return err == nil, nil
cks, err := c.wd.GetCookies()
if err != nil {
return false, err
}
for _, ck := range cks {
if ck.Name == "PHPSESSID" && ck.Domain == "www.rarejob.com" {
return true, nil
}
}
return false, nil
}); err != nil {
return fmt.Errorf("login failed: %w", err)
}
Expand Down

0 comments on commit 38088d4

Please sign in to comment.