lastUserAt should be null if the key has never been used
This commit is contained in:
parent
3e760ca0b8
commit
89dd41d81f
3 changed files with 6 additions and 5 deletions
|
@ -10,9 +10,10 @@ const plusIcon = require('../../../images/plus-icon.svg');
|
|||
|
||||
export const APIKeyPropType = PropTypes.shape({
|
||||
id: PropTypes.object.isRequired,
|
||||
token: PropTypes.object,
|
||||
label: PropTypes.string.isRequired,
|
||||
createdAt: PropTypes.object.isRequired,
|
||||
lastUsedAt: PropTypes.object.isRequired,
|
||||
createdAt: PropTypes.string.isRequired,
|
||||
lastUsedAt: PropTypes.string,
|
||||
});
|
||||
|
||||
class APIKeyForm extends React.Component {
|
||||
|
|
|
@ -22,13 +22,13 @@ function APIKeyList({ apiKeys, onRemove }) {
|
|||
</thead>
|
||||
<tbody>
|
||||
{orderBy(apiKeys, ['createdAt'], ['desc']).map((key) => {
|
||||
const hasNewToken = !!key.token;
|
||||
const lastUsed = key.lastUsedAt ? distanceInWordsToNow(new Date(key.lastUsedAt), { addSuffix: true }) : 'Never';
|
||||
|
||||
return (
|
||||
<tr key={key.id}>
|
||||
<td>{key.label}</td>
|
||||
<td>{format(new Date(key.createdAt), 'MMM D, YYYY h:mm A')}</td>
|
||||
<td>{distanceInWordsToNow(new Date(key.lastUsedAt), { addSuffix: true })}</td>
|
||||
<td>{lastUsed}</td>
|
||||
<td className="api-key-list__action">
|
||||
<button className="api-key-list__delete-button" onClick={() => onRemove(key)}>
|
||||
<InlineSVG src={trashCan} alt="Delete Key" />
|
||||
|
|
|
@ -12,7 +12,7 @@ const { Schema } = mongoose;
|
|||
|
||||
const apiKeySchema = new Schema({
|
||||
label: { type: String, default: 'API Key' },
|
||||
lastUsedAt: { type: Date, required: true, default: Date.now },
|
||||
lastUsedAt: { type: Date },
|
||||
hashedKey: { type: String, required: true },
|
||||
}, { timestamps: true, _id: true });
|
||||
|
||||
|
|
Loading…
Reference in a new issue