首页 \ 问答 \ 保持登录用户信息(Keeping logged in user information)

保持登录用户信息(Keeping logged in user information)

我设法用laravel护照登录。 我有令牌,很棒。 但我想保持登录用户信息,名称,头像等。

我的登录程序获得了oauth令牌。 在仪表板组件中,我对用户数据进行api调用。

我应该将它们保存在全局Vue对象中还是使用Vuex? 安全吗?


I managed to log in with laravel passport. I have the token, great. But I want to keep logged in user information, name, avatar and so on.

My login procedure gets oauth token. In dashboard component I make api call for user data.

Should I keep them in global Vue object or use Vuex? Is it safe?


原文:https://stackoverflow.com/questions/43469358
更新时间:2023-03-03 15:03

最满意答案

最小的变化是传递构造函数(作为函数)而不是ClassTag

abstract class BaseBuilder[A <: BaseBuilder[A]](params: BuilderParams)(constructor: BuilderParams => A) {

  protected def _copy(tuples: (String, Object)*): A = constructor(params ++ tuples)

  def build(): Map[String, Object] = {
    params
  }
}

// or class PizzaBuilder(params: BuilderParams = Map.empty) extends BaseBuilder[PizzaBuilder](params)(new PizzaBuilder(_))
case class PizzaBuilder(params: BuilderParams = Map.empty) extends BaseBuilder[PizzaBuilder](params)(PizzaBuilder)
  with CheeseBuilder[PizzaBuilder]
  with SauceBuilder[PizzaBuilder] {
}

Smallest change would be to pass the constructor (as a function) instead of a ClassTag:

abstract class BaseBuilder[A <: BaseBuilder[A]](params: BuilderParams)(constructor: BuilderParams => A) {

  protected def _copy(tuples: (String, Object)*): A = constructor(params ++ tuples)

  def build(): Map[String, Object] = {
    params
  }
}

// or class PizzaBuilder(params: BuilderParams = Map.empty) extends BaseBuilder[PizzaBuilder](params)(new PizzaBuilder(_))
case class PizzaBuilder(params: BuilderParams = Map.empty) extends BaseBuilder[PizzaBuilder](params)(PizzaBuilder)
  with CheeseBuilder[PizzaBuilder]
  with SauceBuilder[PizzaBuilder] {
}

相关问答

更多
  • 你可以使用Ping的rxb : year = member("1", "2") + digit*3 month = either("Jan", "Feb", "Mar") day = digit*2 hour_mins = digit*2 + ":" + digit*2 date = month + " " + day + ", " + year + ", " + hour_mins 然后您可以直接在结果日期进行匹配,或者使用 DateR = date.compile() You could use ...
  • 最小的变化是传递构造函数(作为函数)而不是ClassTag : abstract class BaseBuilder[A <: BaseBuilder[A]](params: BuilderParams)(constructor: BuilderParams => A) { protected def _copy(tuples: (String, Object)*): A = constructor(params ++ tuples) def build(): Map[String, Objec ...
  • 虽然确实如果结果的使用比结果的计算要昂贵得多,那么对结果的调用可以忽略不计,因为你使用的是不可变结果,每次重新计算都没有意义。 无论如何,在这里查看源代码,对结果的调用似乎相当优化。 尽管如此,我不明白为什么你不想在某处保存结果:尽管有一点改进,但它是免费的:) While it's true that, if the usage of result is much more expensive than the computation of result, then the call to result ...
  • 数学形式语言与编程中更多口语语言的混合使这些对话变得困难。 你在这里处理两个上下文加载的单词:“可组合”和“功能”。 函数构成 - 数学 “函数” A → B的数学概念是从某个集合A到某个集合B的映射,“函数组合”是由∘表示的特定操作。 对于某些f: A → B和g: B → C , f∘g是一个函数A → C ,使得对于A所有x , (f∘g)(x) = f(g(x)) 。 如果它们的域/ codomain以这种方式匹配(换句话说,这样的一对函数“可以被组合”),那么这个组合被定义为任何两个函数,并且我们 ...
  • 这似乎是应用接口隔离原则的一个好例子 具体而言,不是拥有主要的Composable协议,而是拥有许多较小的协议,如UserComposing和WalletComposing 。 那么你希望组成这些不同特征的具体类型只会将它们的“requiredComponents”列为它们所遵循的协议,即: class FlowController : UserComposing, WalletComposing 我实际上写了一篇博文 ,更广泛地讨论了这个问题,并在http://www.danielhall.io/a- ...
  • 您应该使用Seq[String]变体,因为您的args中有空格字符可能用于错误地分隔参数。 尝试 Seq("git", "--git-dir", s"${repository.localLocation.get.path}/.git", "log", "--format='%h %at %s'", "--no-decorate").!! 另请注意,您将在输出中看到单个刻度'。 你可能想要"--format=%h %at %s" 。 You should probably use the Seq[Str ...
  • 要在F#中执行此操作,您需要使用稍微不同的方法。 您需要构造引用的F#代码,而不是使用方法调用(和延迟执行)来组成查询。 如果您只需要通过某个数字参数来参数化代码,则可以编写一个运行查询的函数: let takeData count = <@ seq { for i in context.MyTable do if x.Parameter > 10 then yield i } |> Seq.take count @> |> que ...
  • 每个Scala系列都带有附加构建器: val keysB, dataB = Vector.newBuilder[String] for ((k, v) <- myMap) { if (v.endsWith("abc")) { keysB += v } if (v.endsWith("xyz")) { dataB += v } } val keys = keysB.result() val data = dataB.result() Every Scala collection comes wi ...
  • 实际上,解决方案非常简单。 var compose = require('composable-middleware'); sinon.stub(auth, 'isAuthenticated', function() { return compose() .use(function (req, res, next) { next(); }); }); Actually, the solution was pretty simple. var compo ...
  • 我不确定为什么要使用存储Class信息的变量。 使用标准泛型,解决方案应该更简单: trait Builder[A,B] { def process(input: A): B } case class ComposedBuilder[A,B,C](b1: Builder[A,B], b2: Builder[B,C]) extends Builder[A,C] { def process(input: A): C = b2.process(b1.process(input)) } 然后你可以让你的 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)