保持登录用户信息(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] { }
相关问答
更多-
Python中的可组合正则表达式(Composable Regexp in Python)[2022-06-02]
你可以使用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- ...
-
Scala Process Builder(Scala Process Builder)[2022-03-22]
您应该使用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 ... -
可组合的FLinq表达式(Composable FLinq expressions)[2022-07-02]
要在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)) } 然后你可以让你的 ...