//func (n *Node) Login(ctx ct.Context, name, pwd string) error {
//	return n.Call(ctx, "$", "Login", nil, nil)
//}
515443
func (n *Node) handle() {
	resp := &Response{}
	for n.state == stateReady {
		err := n.codec.DecodeHead(&resp.Head)
		if err != nil {
			if n.state != stateShutdown {
				n.logger.Error("client > failed to decode head: ", err)
				n.Close()
			}
			break
		}

		if resp.Head.ID == 0 {
			n.heartbeat()
			continue
		}

		c := n.calls.Find(resp.Head.ID)
		if c == nil { // unknown response or request is timeout.
			n.codec.DiscardResult()
			n.logger.Error("client > unknown request: ", resp.Head.ID)
			continue
		}

		resp.Result.Value = c.reply
		err = n.codec.DecodeResult(&resp.Result)
		if err != nil {
			n.logger.Error("client > failed to decode result: ", err)
		} else if resp.Result.Error != nil {
			err = resp.Result.Error
		}
		c.finish(err)
	}

	n.calls.Clear(func(c *Call) {
		c.finish(ErrNodeShutdown)
	})
}
367914
func (c *Client) Login(ctx context.Context) (err error) {
	var req *APIRequest
	var resp *APIResponse

	req, err = c.NewRequest("GET", "api/agents", nil, apiV2)
	if err != nil {
		return
	}
	req.HTTP.SetBasicAuth(c.params.Username, c.params.Password)

	resp, err = c.Do(ctx, req, nil, responseTypeJSON)
	if err == nil {
		c.cookie = resp.HTTP.Header["Set-Cookie"][0]
	}
	return
}
712371
func UserLogin(username, password string, loginSourceID int64) (*User, error) {
	var user *User
	if strings.Contains(username, "@") {
		user = &User{Email: strings.ToLower(username)}
	} else {
		user = &User{LowerName: strings.ToLower(username)}
	}

	hasUser, err := x.Get(user)
	if err != nil {
		return nil, fmt.Errorf("get user record: %v", err)
	}

	if hasUser {
		// Note: This check is unnecessary but to reduce user confusion at login page
		// and make it more consistent at user's perspective.
		if loginSourceID >= 0 && user.LoginSource != loginSourceID {
			return nil, errors.LoginSourceMismatch{loginSourceID, user.LoginSource}
		}

		// Validate password hash fetched from database for local accounts
		if user.LoginType == LOGIN_NOTYPE ||
			user.LoginType == LOGIN_PLAIN {
			if user.ValidatePassword(password) {
				return user, nil
			}

			return nil, errors.UserNotExist{user.ID, user.Name}
		}

		// Remote login to the login source the user is associated with
		source, err := GetLoginSourceByID(user.LoginSource)
		if err != nil {
			return nil, err
		}

		return remoteUserLogin(user, user.LoginName, password, source, false)
	}

	// Non-local login source is always greater than 0
	if loginSourceID <= 0 {
		return nil, errors.UserNotExist{-1, username}
	}

	source, err := GetLoginSourceByID(loginSourceID)
	if err != nil {
		return nil, err
	}

	return remoteUserLogin(nil, username, password, source, true)
}
1100719
func (i *Instagram) Login() error {

	fetch := APIURL + "/si/fetch_headers/?challenge_type=signup&guid=" + generateUUID(false)

	resp, err := i.requestLogin("GET", fetch, nil)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	// get csrftoken
	for _, cookie := range resp.Cookies() {
		if cookie.Name == "csrftoken" {
			i.token = cookie.Value
		}
	}

	// login
	login := &Login{
		DeviceID:          i.deviceID,
		GUID:              i.uuid,
		UserName:          i.userName,
		Password:          i.password,
		Csrftoken:         i.token,
		LoginAttemptCount: "0",
	}

	jsonData, err := json.Marshal(login)
	if err != nil {
		return err
	}

	signature := generateSignature(jsonData)

	resp, err = i.requestLogin("POST", APIURL+"/accounts/login/?", bytes.NewReader([]byte(signature)))
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	// get new csrftoken
	for _, cookie := range resp.Cookies() {
		if cookie.Name == "csrftoken" {
			i.token = cookie.Value
		}
	}
	i.cookies = resp.Cookies()

	var object *LoginResponse
	decoder := json.NewDecoder(resp.Body)
	err = decoder.Decode(&object)
	if err != nil {
		return err
	}

	if object.Status == "fail" {
		return errors.New(object.Message)
	}

	i.userNameID = object.LoggedInUser.Pk
	i.rankToken = strconv.FormatInt(i.userNameID, 10) + "_" + i.uuid

	return nil
}
1259099
func (m *AuthMethod) loginHandler(ctx *router.Context) {
	c, rw, r := ctx.Context, ctx.Writer, ctx.Request

	dest, err := normalizeURL(r.URL.Query().Get("r"))
	if err != nil {
		replyError(c, rw, err, "Bad redirect URI (%q) - %s", dest, err)
		return
	}

	cfg, err := fetchCachedSettings(c)
	if err != nil {
		replyError(c, rw, err, "Can't load OpenID settings - %s", err)
		return
	}

	// `state` will be propagated by OpenID backend and will eventually show up
	// in callback URI handler. See callbackHandler.
	state := map[string]string{
		"dest_url": dest,
		"host_url": r.Host,
	}
	authURI, err := authenticationURI(c, cfg, state)
	if err != nil {
		replyError(c, rw, err, "Can't generate authentication URI - %s", err)
		return
	}
	http.Redirect(rw, r, authURI, http.StatusFound)
}
984660
func (c *client) User(login string) (*User, error) {
	out := new(User)
	uri := fmt.Sprintf(pathUser, c.addr, login)
	err := c.get(uri, out)
	return out, err
}
176935
func (c *Contributor) GetLogin() string {
	if c == nil || c.Login == nil {
		return ""
	}
	return *c.Login
}
602931
func (lcmd *loginCommand) Login(policy *ClientPolicy, conn *Connection) error {
	hashedPass, err := hashPassword(policy.Password)
	if err != nil {
		return err
	}

	return lcmd.login(policy, conn, hashedPass)
}
709193
func (c *Client) LoginUser(username, password string, user User) error {
	uri, _ := url.Parse("/1/login")
	params := url.Values{}
	params.Add("username", username)
	params.Add("password", password)
	uri.RawQuery = params.Encode()

	resp, err := c.doSimple("GET", uri.String())
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	c.trace("LoginUser", uri, string(body))
	// TODO(tmc): warn if not == .Zero() before populating?
	return json.Unmarshal(body, user)
}
757814
func Login(email, passwd, apikey string) (*Conn, error) {
	c := &Conn{}
	var out loginResult
	if err := c.do("smugmug.login.withPassword", &out, "APIKey", apikey, "EmailAddress", email, "Password", passwd); err != nil {
		return nil, err
	}

	c.sessid = out.Login.Session.ID
	if c.sessid == "" {
		return nil, fmt.Errorf("SmugMug login appeared to succeed but did not return session ID")
	}

	c.NickName = out.Login.User.NickName
	if c.NickName == "" {
		return nil, fmt.Errorf("SmugMug login appeared to succeed but did not return User NickName")
	}

	return c, nil
}
97325
func (c *Ctx) Login(sh SessionHandle, userType uint, pin string) error {
	p := C.CString(pin)
	defer C.free(unsafe.Pointer(p))
	e := C.Login(c.ctx, C.CK_SESSION_HANDLE(sh), C.CK_USER_TYPE(userType), p, C.CK_ULONG(len(pin)))
	return toError(e)
}
250104
func (state *UserState) Login(w http.ResponseWriter, username string) error {
	state.SetLoggedIn(username)
	return state.SetUsernameCookie(w, username)
}
746768
func (c *linkedInConnector) LoginURL(scopes connector.Scopes, callbackURL, state string) (string, error) {
	if c.oauth2Config.RedirectURL != callbackURL {
		return "", fmt.Errorf("expected callback URL %q did not match the URL in the config %q",
			callbackURL, c.oauth2Config.RedirectURL)
	}

	return c.oauth2Config.AuthCodeURL(state), nil
}
1170537
func Login(cookie string, secret []byte) string {
	l, exp, err := Parse(cookie, secret)
	if err != nil || exp.Before(time.Now()) {
		return ""
	}
	return l
}
847051
func (n *NotifyRouter) HandleLogin(ctx context.Context, u string) {
	if n == nil {
		return
	}
	n.G().Log.CDebugf(ctx, "+ Sending login notification, as user %q", u)
	// For all connections we currently have open...
	ctx = CopyTagsToBackground(ctx)
	n.cm.ApplyAll(func(id ConnectionID, xp rpc.Transporter) bool {
		// If the connection wants the `Session` notification type
		if n.getNotificationChannels(id).Session {
			// In the background do...
			go func() {
				// A send of a `LoggedIn` RPC
				(keybase1.NotifySessionClient{
					Cli: rpc.NewClient(xp, NewContextifiedErrorUnwrapper(n.G()), nil),
				}).LoggedIn(ctx, u)
			}()
		}
		return true
	})

	n.runListeners(func(listener NotifyListener) {
		listener.Login(u)
	})
	n.G().Log.CDebugf(ctx, "- Login notification sent")
}
129527
func (sw *SplunkHandler) login() (string, error) {
	splunkURL, _ := url.Parse(sw.url.String())
	splunkURL.Path = splunkURL.Path + "services/auth/login"

	values := &url.Values{}
	values.Set("username", sw.username)
	values.Set("password", sw.password)
	values.Set("output_mode", "json")

	resp, err := sw.client.PostForm(splunkURL.String(), *values)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()

	if resp.StatusCode == 401 {
		return "", fmt.Errorf("unauthorized")
	}

	buf, _ := ioutil.ReadAll(resp.Body)

	respData := struct{ SessionKey string }{}
	if err := json.Unmarshal(buf, &respData); err != nil {
		return "", err
	}

	if respData.SessionKey == "" {
		return "", fmt.Errorf("failed to obtain sessionKey in response")
	}

	return respData.SessionKey, nil
}
590021
func (a *ACL) Login(auth *ACLLoginParams, q *WriteOptions) (*ACLToken, *WriteMeta, error) {
	r := a.c.newRequest("POST", "/v1/acl/login")
	r.setWriteOptions(q)
	r.obj = auth

	rtt, resp, err := requireOK(a.c.doRequest(r))
	if err != nil {
		return nil, nil, err
	}
	defer resp.Body.Close()

	wm := &WriteMeta{RequestTime: rtt}
	var out ACLToken
	if err := decodeBody(resp, &out); err != nil {
		return nil, nil, err
	}
	return &out, wm, nil
}