小编vip*_*169的帖子

宝石“devise_token_auth”方法:authenticate_user!尽管有效的身份验证参数返回 401

我正在尝试使用 gem“devise_token_auth”对每个 json api 请求对用户进行身份验证。但是,我也想支持旧设备身份验证"config.enable_standard_devise_support = true"

#app/controllers/api/v1/api_controller.rb
class Api::V1::ApiController < ApplicationController
  respond_to :json
  include DeviseTokenAuth::Concerns::SetUserByToken
  before_filter :authenticate_user_from_token!
  ....
  def authenticate_user_from_token!
    user_email = request.headers["X-User-Email"].presence || request.headers["uid"].presence
    client_id = request.headers["client"].presence
    access_token = request.headers["access-token"].presence
    user = user_email && User.find_by_email(user_email)
    auth_token = request.headers["X-Auth-Token"].presence
    if user && auth_token && Devise.secure_compare(user.authentication_token, auth_token)
      sign_in user, store: false
      authenticate_user!
    elsif access_token && client_id && user && user.valid_token?(access_token, client_id)
      authenticate_user!
    else
      throw(:warden, scope: :user)
    end
  end
  ....
end
Run Code Online (Sandbox Code Playgroud)

以下是对应的rspec

describe "Sign In" do
      it "allows further api …
Run Code Online (Sandbox Code Playgroud)

ruby devise ruby-on-rails-4 postman

5
推荐指数
0
解决办法
550
查看次数

如何在运行时为补间动画更改endValueString?

我正在使用Unity商店中的DOTween pro资产以及textmeshpro.附件是显示我的设置的屏幕截图:

在此输入图像描述

我的场景中收藏品很少; 我希望每次收集项目时能够使用不同的文本运行动画.

以下是我的代码片段:

DOTweenAnimation[] animations = pickUpTexts.GetComponents<DOTweenAnimation>();
for(int i=0;i< animations.Length; i++)
{
    Debug.Log("animations " + animations[0].animationType);
    if (animations[i].animationType == DOTweenAnimationType.Text)
    {
        textAnimation = animations[i];
    }
    if (animations[i].animationType == DOTweenAnimationType.Move)
    {
        moveAnimation = animations[i];
    }
}
Run Code Online (Sandbox Code Playgroud)

以后收集项目时,我称之为:

textAnimation.endValueString = "New pick up collected, blah blah";
//textAnimation.DOPlay();
textAnimation.DORestart();
Run Code Online (Sandbox Code Playgroud)

基本上,我正在尝试更改endValueString动画并使用新值重新运行动画.收集拾取后,我可以endValueString在检查器中看到正在更新,但补间仍在播放(或不播放)相同的旧值.显示更新的屏幕截图如下所示: 在此输入图像描述

我尝试使用重新启动/播放更改,关闭组件的自动杀戮选项,尝试更改检查器中的循环计数器,尝试使用textAnimation.DORestart(true)但似乎没有任何工作.

到目前为止我找到的解决方案是不使用动画组件,因为它不可重复使用,只需在我的脚本中使用以下行:

pickUpTexts.GetComponent<TextMeshProUGUI>().DOText("New pick up collected, blah blah", 1f, true).SetRelative(true)
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine dotween

3
推荐指数
1
解决办法
1154
查看次数

超时后消除反应错误消息

我正在尝试显示一些反应错误消息并在 5 秒超时后隐藏它们。下面是代码:

import * as React from 'react'
import {ErrorInfo} from '../Twilio/api'
export const Error = ({type, message, visible}: ErrorInfo) => (
    // visible=true,
    setTimeout(function () {
        visible = false
    }, 5000),
        visible ?
            <div>
                <p>
                    <strong>{type}:</strong> {message}
                    <br/>
                    <small>
                        UI version: <code>{GLOBAL_VERSION}</code>
                    </small>
                </p>
            </div> : <span/>
)
Run Code Online (Sandbox Code Playgroud)

ErrorInfo如下:

export type ErrorInfo = {
    type: string
    message: string
    visible: boolean
}
Run Code Online (Sandbox Code Playgroud)

但是,visible被设置为未定义,因此不会显示错误消息。如果我在导出时将其设置为 true ,那么当它变为 false 时,元素不会被删除,从而Error显示它。Headervisible

reactjs tsx twilio-programmable-chat

2
推荐指数
1
解决办法
4605
查看次数

"devise_token_auth"gem是否支持基于Web的身份验证?

此gem(" devise_token_auth ")用于使用JSON API进行前端开发的应用程序的令牌身份验证.我们可以将这个gem用于服务器端渲染吗?如果是,那么如何将先前响应中的令牌添加到当前请求中?

rubygems devise ruby-on-rails-4.2

1
推荐指数
1
解决办法
966
查看次数

使用selenium在DOM层次结构中向上移动

我想访问一个DOM元素,它位于层次结构之上,是我有权访问的元素.

在Attached ScreenShot中,我想访问#nRD_1的Grand Grand Grand Parent的#pRow_22.但我只能访问#ntsDiv_1.请建议我在这种情况下做什么

在此输入图像描述

HTML代码是这样的: -

<tr id="pRow_22" style="border-bottom: 0;">
<td class="nameCell" style="border-bottom: 1px solid #CCCCCC;">
    <div id="seller_22" class="product-sellercell">
        <a id="pLogoLink_22" target="_blank" href="/norob/ClickTracker.somethins..." onclick="setMerchLb('eComElectronics.com')" rel="nofollow">
        <div>
            <a id="ntsLink_1" rel="nofollow" onclick="return false;" href="#">
        </div>
        <div id="ntsDiv_1" class="mlt-pop-container" style="width: 250px; text-align: left; white-space: normal; top: 2340px; left: 131px; visibility: hidden;">
            <div class="mlt-pop-bg">
        </div>
        .
        .   
        </div>
</td>
Run Code Online (Sandbox Code Playgroud)

selenium dom webdriver

0
推荐指数
1
解决办法
2007
查看次数