// ForgetAccountHandler handles the actuall "forgetting" of an account, by dropping the validated email and phone numbers
// from the respective collections
355913
func (service *Service) ForgetAccountHandler(w http.ResponseWriter, r *http.Request) {
	// If we are not in a test environment, we pretend this does not exist
	// Don't worry about it
	if !service.testEnv {
		http.Error(w, "404 page not found", http.StatusNotFound)
		return
	}

	r.ParseForm()
	login := strings.ToLower(r.FormValue("login"))

	u, err := organization.SearchUser(r, login)
	if db.IsNotFound(err) {
		w.WriteHeader(422)
		return
	} else if err != nil {
		log.Error("Failed to search for user: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	userexists := !db.IsNotFound(err)

	var validpassword bool
	passwdMgr := password.NewManager(r)
	if validpassword, err = passwdMgr.Validate(u.Username, r.FormValue("password")); err != nil {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	if !userexists || !validpassword {
		w.WriteHeader(422)
		log.Debug("Invalid password for forgetting user")
		return
	}

	// drop validated info
	valMgr := validation.NewManager(r)
	validatedEmails, err := valMgr.GetByUsernameValidatedEmailAddress(u.Username)
	if err != nil {
		log.Error("Failed to get validated email addresses: ", err)
		return
	}

	for _, ve := range validatedEmails {
		// I can't be asked to care about the errors here, its past 11.30PM and its only for dev/staging anyway
		valMgr.RemoveValidatedEmailAddress(u.Username, ve.EmailAddress)
	}

	validatedPhones, err := valMgr.GetByUsernameValidatedPhonenumbers(u.Username)
	if err != nil {
		log.Error("Failed to get validated phone numbers: ", err)
		return
	}

	for _, vp := range validatedPhones {
		// Same as above
		valMgr.RemoveValidatedPhonenumber(u.Username, vp.Phonenumber)
	}

	w.WriteHeader(http.StatusOK)

	const template = `
	<html>
		<body>
			<h3>
				Your validated info has been forgotten and can now be reused
			</h3>
		</body>
	</html>
	`

	w.Write([]byte(template))
}
824015
func HandleCredentialError(isAuthError func(error) bool, err error, ctx context.ProviderCallContext) {
	MaybeHandleCredentialError(isAuthError, err, ctx)
}
238677
func (l *Client) GetAccount(id string) (Account, error) {
	res := ApiResp{}
	data := Account{}

	// make the request
	err := l.Get(parseLyticsURL(accountEndpoint, map[string]string{"id": id}), nil, nil, &res, &data)
	if err != nil {
		return data, err
	}

	return data, nil
}
483031
func unregisterHandler(handlerIndex int) {
	handlerMu.Lock()
	defer handlerMu.Unlock()

	delete(handlers, handlerIndex)
}
1102947
func (c *Client) GetAccountAddress(account string) (btcutil.Address, error) {
	return c.GetAccountAddressAsync(account).Receive()
}
820828
func (a adminAPIHandlers) RemoveUser(w http.ResponseWriter, r *http.Request) {
	ctx := newContext(r, w, "RemoveUser")

	objectAPI := validateAdminReq(ctx, w, r)
	if objectAPI == nil {
		return
	}

	// Deny if WORM is enabled
	if globalWORMEnabled {
		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMethodNotAllowed), r.URL)
		return
	}

	vars := mux.Vars(r)
	accessKey := vars["accessKey"]
	if err := globalIAMSys.DeleteUser(accessKey); err != nil {
		writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
	}
}
1125142
func (client *Client) DeleteAccount(instanceId, accountName string) (resp *DeleteAccountResponse, err error) {
	args := DeleteAccountArgs{
		DBInstanceId: instanceId,
		AccountName:  accountName,
	}

	response := DeleteAccountResponse{}
	err = client.Invoke("DeleteAccount", &args, &response)

	if err != nil {
		return nil, err
	}
	return &response, nil
}
14796
func (s *Server) forgetConn(c net.Conn) {
	if _, ok := s.conns[c]; ok {
		delete(s.conns, c)
		s.wg.Done()
	}
}
984924
func (api *API) UpdateAccount(accountID string, account Account) (Account, error) {
	uri := "/accounts/" + accountID

	res, err := api.makeRequest("PUT", uri, account)
	if err != nil {
		return Account{}, errors.Wrap(err, errMakeRequestError)
	}

	var a AccountDetailResponse
	err = json.Unmarshal(res, &a)
	if err != nil {
		return Account{}, errors.Wrap(err, errUnmarshalError)
	}

	return a.Result, nil
}
608066
func (s *ResourceIdentifier) SetAccount(v string) *ResourceIdentifier {
	s.Account = &v
	return s
}
851127
func (c *Client) GetAccount(address btcutil.Address) (string, error) {
	return c.GetAccountAsync(address).Receive()
}
1111975
func (c *Client) RenameAccount(oldAccount, newAccount string) error {
	return c.RenameAccountAsync(oldAccount, newAccount).Receive()
}
1154194
func (a *Authenticator) PurgeCredentialsCache() error {
	a.lock.Lock()
	defer a.lock.Unlock()
	if err := a.ensureInitialized(); err != nil {
		return err
	}
	return a.purgeCredentialsCacheLocked()
}
210623
func (api *Client) GetAccount() (*Account, error) {
	result, _, err := api.makeRequest(http.MethodGet, api.concatUserPath(accountPath), &Account{})
	if err != nil {
		return nil, err
	}
	return result.(*Account), nil
}
666640
func (a *AddrManager) addressHandler() {
	dumpAddressTicker := time.NewTicker(dumpAddressInterval)
	defer dumpAddressTicker.Stop()
out:
	for {
		select {
		case <-dumpAddressTicker.C:
			a.savePeers()

		case <-a.quit:
			break out
		}
	}
	a.savePeers()
	a.wg.Done()
	log.Trace("Address handler done")
}
1097225
func (s *Server) updateAccount(acc *Account) error {
	// TODO(dlc) - Make configurable
	if time.Since(acc.updated) < time.Second {
		s.Debugf("Requested account update for [%s] ignored, too soon", acc.Name)
		return ErrAccountResolverUpdateTooSoon
	}
	claimJWT, err := s.fetchRawAccountClaims(acc.Name)
	if err != nil {
		return err
	}
	return s.updateAccountWithClaimJWT(acc, claimJWT)
}
598371
func (c AccountClient) ResetAccount(ctx context.Context, __arg ResetAccountArg) (err error) {
	err = c.Cli.Call(ctx, "keybase.1.account.resetAccount", []interface{}{__arg}, nil)
	return
}