使用cookie解析器解码cookie

时间:2019-09-08 21:37:49

标签: javascript express express-session

我正在尝试解码如下所示的cookie(没有成功):constructor() { super() this.state = { udata: [] } this.onSort = this.onSort.bind(this) let connection = new signalR.HubConnectionBuilder() .withUrl("/signalserver") .build(); connection.start().then(function () { }).catch(function (err) { return console.error(err.toString()); }); connection.on("APIDataChannel", function (data) { this.setState({ udata: data }); // console.log(data); }.bind(this)); async function start() { try { await connection.start(); console.log("connected"); } catch (err) { console.log(err); setTimeout(() => start(), 5000); } }; connection.onclose(async () => { await start(); }); } renderItem(item, key) { const itemRows = [ <tr onClick={clickCallback} key={"row-data-" + key}> <td>{item.appName}</td> <td> <h6 className="text-muted"><i className={"fa fa-circle text-c-" + (item.appState === 'STARTED' ? 'green' : 'red') + " f-10 m-r-15"} />{item.appState}</h6> </td> <td>{item.spaceName}</td> <td> <h6 className="text-muted">{item.orgName}</h6> </td> <td> <h6 className="text-muted">{new Date(item.appUpdatedAt).toLocaleString()}</h6> </td> </tr> ]; return itemRows; } onSort(event, sortKey) { const data = this.state.udata; data.sort((a, b) => a[sortKey].localeCompare(b[sortKey])) this.setState({ data }) } render() { let allItemRows = []; this.state.udata.forEach((item, key) => { const perItemRows = this.renderItem(item, key); allItemRows = allItemRows.concat(perItemRows); }); return ( <Aux> <Row> <Table hover responsive> <thead> <tr> <th onClick={e => this.onSort(e, 'appName')}>App Name</th> <th>State</th> <th>Space</th> <th>Organization</th> <th onClick={e => this.onSort(e, 'appUpdatedAt')}>Updated At</th> </tr> </thead> <tbody> {allItemRows} </tbody> </Table> </Row> </Aux> ); }

它是使用express-session模块制作的。

我试图做这样的事情:

s%3Ak0tBm_lnBeH4G5pPIbbFKktQl0l4pNU8.d2ZbSvwFjkmVWfcS9Wn0%2Fi2oSnTYI09krfOOWJAXirE

此输出是signedCookie的第一个参数(“ s%3Ak0tBm _...”)。我期望类似: const cookieParser = require("cookie-parser"); console.log(cookieParser.signedCookie("s%3Ak0tBm_lnBeH4G5pPIbbFKktQl0l4pNU8.d2ZbSvwFjkmVWfcS9Wn0%2Fi2oSnTYI09krfOOWJAXirE", "jksadhjk123io12ejnmlad'132hv8891"));

1 个答案:

答案 0 :(得分:1)

似乎无法在字符串和提供的actions: { fetchProducts({commit}) { return new Promise((resolve, reject) => { // make the call // call setProducts mutation shop.getProducts(products => { commit('setProducts', products) resolve() }) }) } 之间验证签名。注意语法是:

<%= form_for @person do |person_form| %>
  <%= person_form.fields_for :projects, child_index: 0 do |project_fields| %>
    <%= project_fields.index %>
  <% end %>
<% end %>

请参见this reference,该说明会同时显示

  

如果未签名,则返回原始值。

  

如果该值已签名但无法验证签名,   返回false。