当前位置: 首页>>代码示例>>Golang>>正文


Golang LoginContext.LocalSession方法代码示例

本文整理汇总了Golang中github.com/keybase/client/go/libkb.LoginContext.LocalSession方法的典型用法代码示例。如果您正苦于以下问题:Golang LoginContext.LocalSession方法的具体用法?Golang LoginContext.LocalSession怎么用?Golang LoginContext.LocalSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/keybase/client/go/libkb.LoginContext的用法示例。


在下文中一共展示了LoginContext.LocalSession方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: WriteOut

func (s *SignupJoinEngine) WriteOut(lctx libkb.LoginContext, salt []byte) error {
	if err := lctx.LocalSession().Load(); err != nil {
		return err
	}
	if err := lctx.CreateLoginSessionWithSalt(s.username.String(), salt); err != nil {
		return err
	}
	if err := lctx.SaveState(s.session, s.csrf, s.username, s.uid); err != nil {
		return err
	}
	return nil
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:12,代码来源:signup_join.go

示例2: postLogin

func (e *LoginEngine) postLogin(ctx *Context, lctx libkb.LoginContext) error {
	// We might need to ID ourselves, so load us in here
	var err error
	arg := libkb.NewLoadUserForceArg(e.G())
	arg.LoginContext = lctx
	e.user, err = libkb.LoadMe(arg)
	if err != nil {
		_, ok := err.(libkb.NoKeyError)
		if !ok {
			return err
		}
	}

	if e.SkipLocksmith {
		ctx.LogUI.Debug("skipping locksmith as requested by LoginArg")
		return nil
	}

	// create a locksmith engine to check the account

	ctx.LoginContext = lctx
	larg := &LocksmithArg{
		User:      e.user,
		CheckOnly: true,
	}
	e.locksmith = NewLocksmith(larg, e.G())
	if err := RunEngine(e.locksmith, ctx); err != nil {
		return err
	}
	if e.locksmith.Status().CurrentDeviceOk {
		if err := lctx.LocalSession().SetDeviceProvisioned(e.G().Env.GetDeviceID()); err != nil {
			// not a fatal error, session will stay in memory
			e.G().Log.Warning("error saving session file: %s", err)
		}
		return nil
	}

	// need to provision this device

	// need to have passphrase stream cached in order to provision a device
	if lctx.PassphraseStreamCache() == nil {
		// this can happen if:
		// 1. The user is logging in for the first time on a device.
		// 2. Before the device is provisioned, the login is canceled or
		//    interrupted.
		// 3. The daemon restarts (`ctl stop`, machine reboot, bug, etc.)
		// 4. The login session is still valid, so the next login attempt
		//    does not require passphrase.
		//
		// (Note that pubkey login isn't an option until the device is
		// provisioned.)
		//
		// 5. So they get to here without entering their passphrase
		//    and without a cached passphrase stream.
		//    Locksmith won't be able to provision the device without
		//    the passphrase stream, and we can't do
		//    LoginState.verifyPassphraseWithServer since that creates
		//    a new login request and we are in the middle of a login
		//    request.
		//
		// The best we can do here is to logout and tell the user to
		// login again.  This should be a rare scenario.
		//
		lctx.Logout()
		ctx.LogUI.Info("Please run `keybase login` again.  There was an unexpected error since your previous login.")
		return libkb.ReloginRequiredError{}
	}

	larg.CheckOnly = false
	e.locksmith = NewLocksmith(larg, e.G())
	if err := RunEngine(e.locksmith, ctx); err != nil {
		if _, canceled := err.(libkb.CanceledError); canceled {
			lctx.Logout()
		}
		return err
	}

	if err := lctx.LocalSession().SetDeviceProvisioned(e.G().Env.GetDeviceID()); err != nil {
		// not a fatal error, session will stay in memory
		e.G().Log.Warning("error saving session file: %s", err)
	}
	return nil
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:83,代码来源:login.go


注:本文中的github.com/keybase/client/go/libkb.LoginContext.LocalSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。