chore: Rename Authentication
-> IntegrationAuthentication
(#2091)
This commit is contained in:
@ -5,13 +5,13 @@ import { AuthenticationError, InvalidRequestError } from "../errors";
|
|||||||
import {
|
import {
|
||||||
UserAuthentication,
|
UserAuthentication,
|
||||||
AuthenticationProvider,
|
AuthenticationProvider,
|
||||||
Authentication,
|
|
||||||
Document,
|
Document,
|
||||||
User,
|
User,
|
||||||
Team,
|
Team,
|
||||||
Collection,
|
Collection,
|
||||||
SearchQuery,
|
SearchQuery,
|
||||||
Integration,
|
Integration,
|
||||||
|
IntegrationAuthentication,
|
||||||
} from "../models";
|
} from "../models";
|
||||||
import { presentSlackAttachment } from "../presenters";
|
import { presentSlackAttachment } from "../presenters";
|
||||||
import * as Slack from "../slack";
|
import * as Slack from "../slack";
|
||||||
@ -38,7 +38,7 @@ router.post("hooks.unfurl", async (ctx) => {
|
|||||||
});
|
});
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
const auth = await Authentication.findOne({
|
const auth = await IntegrationAuthentication.findOne({
|
||||||
where: { service: "slack", teamId: user.teamId },
|
where: { service: "slack", teamId: user.teamId },
|
||||||
});
|
});
|
||||||
if (!auth) return;
|
if (!auth) return;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable flowtype/require-valid-file-annotation */
|
/* eslint-disable flowtype/require-valid-file-annotation */
|
||||||
import TestServer from "fetch-test-server";
|
import TestServer from "fetch-test-server";
|
||||||
import app from "../app";
|
import app from "../app";
|
||||||
import { Authentication, SearchQuery } from "../models";
|
import { IntegrationAuthentication, SearchQuery } from "../models";
|
||||||
import * as Slack from "../slack";
|
import * as Slack from "../slack";
|
||||||
import { buildDocument, buildIntegration } from "../test/factories";
|
import { buildDocument, buildIntegration } from "../test/factories";
|
||||||
import { flushdb, seed } from "../test/support";
|
import { flushdb, seed } from "../test/support";
|
||||||
@ -18,7 +18,7 @@ jest.mock("../slack", () => ({
|
|||||||
describe("#hooks.unfurl", () => {
|
describe("#hooks.unfurl", () => {
|
||||||
it("should return documents", async () => {
|
it("should return documents", async () => {
|
||||||
const { user, document } = await seed();
|
const { user, document } = await seed();
|
||||||
await Authentication.create({
|
await IntegrationAuthentication.create({
|
||||||
service: "slack",
|
service: "slack",
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
|
@ -6,7 +6,12 @@ import accountProvisioner from "../../commands/accountProvisioner";
|
|||||||
import env from "../../env";
|
import env from "../../env";
|
||||||
import auth from "../../middlewares/authentication";
|
import auth from "../../middlewares/authentication";
|
||||||
import passportMiddleware from "../../middlewares/passport";
|
import passportMiddleware from "../../middlewares/passport";
|
||||||
import { Authentication, Collection, Integration, Team } from "../../models";
|
import {
|
||||||
|
IntegrationAuthentication,
|
||||||
|
Collection,
|
||||||
|
Integration,
|
||||||
|
Team,
|
||||||
|
} from "../../models";
|
||||||
import * as Slack from "../../slack";
|
import * as Slack from "../../slack";
|
||||||
import { StateStore } from "../../utils/passport";
|
import { StateStore } from "../../utils/passport";
|
||||||
|
|
||||||
@ -113,7 +118,7 @@ if (SLACK_CLIENT_ID) {
|
|||||||
const endpoint = `${process.env.URL || ""}/auth/slack.commands`;
|
const endpoint = `${process.env.URL || ""}/auth/slack.commands`;
|
||||||
const data = await Slack.oauthAccess(code, endpoint);
|
const data = await Slack.oauthAccess(code, endpoint);
|
||||||
|
|
||||||
const authentication = await Authentication.create({
|
const authentication = await IntegrationAuthentication.create({
|
||||||
service: "slack",
|
service: "slack",
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
@ -168,7 +173,7 @@ if (SLACK_CLIENT_ID) {
|
|||||||
const endpoint = `${process.env.URL || ""}/auth/slack.post`;
|
const endpoint = `${process.env.URL || ""}/auth/slack.post`;
|
||||||
const data = await Slack.oauthAccess(code, endpoint);
|
const data = await Slack.oauthAccess(code, endpoint);
|
||||||
|
|
||||||
const authentication = await Authentication.create({
|
const authentication = await IntegrationAuthentication.create({
|
||||||
service: "slack",
|
service: "slack",
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
|
@ -26,7 +26,7 @@ Integration.associate = (models) => {
|
|||||||
as: "collection",
|
as: "collection",
|
||||||
foreignKey: "collectionId",
|
foreignKey: "collectionId",
|
||||||
});
|
});
|
||||||
Integration.belongsTo(models.Authentication, {
|
Integration.belongsTo(models.IntegrationAuthentication, {
|
||||||
as: "authentication",
|
as: "authentication",
|
||||||
foreignKey: "authenticationId",
|
foreignKey: "authenticationId",
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import { DataTypes, sequelize, encryptedFields } from "../sequelize";
|
import { DataTypes, sequelize, encryptedFields } from "../sequelize";
|
||||||
|
|
||||||
const Authentication = sequelize.define("authentication", {
|
const IntegrationAuthentication = sequelize.define("authentication", {
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
defaultValue: DataTypes.UUIDV4,
|
defaultValue: DataTypes.UUIDV4,
|
||||||
@ -12,15 +12,15 @@ const Authentication = sequelize.define("authentication", {
|
|||||||
token: encryptedFields().vault("token"),
|
token: encryptedFields().vault("token"),
|
||||||
});
|
});
|
||||||
|
|
||||||
Authentication.associate = (models) => {
|
IntegrationAuthentication.associate = (models) => {
|
||||||
Authentication.belongsTo(models.User, {
|
IntegrationAuthentication.belongsTo(models.User, {
|
||||||
as: "user",
|
as: "user",
|
||||||
foreignKey: "userId",
|
foreignKey: "userId",
|
||||||
});
|
});
|
||||||
Authentication.belongsTo(models.Team, {
|
IntegrationAuthentication.belongsTo(models.Team, {
|
||||||
as: "team",
|
as: "team",
|
||||||
foreignKey: "teamId",
|
foreignKey: "teamId",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Authentication;
|
export default IntegrationAuthentication;
|
@ -1,7 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import ApiKey from "./ApiKey";
|
import ApiKey from "./ApiKey";
|
||||||
import Attachment from "./Attachment";
|
import Attachment from "./Attachment";
|
||||||
import Authentication from "./Authentication";
|
|
||||||
import AuthenticationProvider from "./AuthenticationProvider";
|
import AuthenticationProvider from "./AuthenticationProvider";
|
||||||
import Backlink from "./Backlink";
|
import Backlink from "./Backlink";
|
||||||
import Collection from "./Collection";
|
import Collection from "./Collection";
|
||||||
@ -12,6 +11,7 @@ import Event from "./Event";
|
|||||||
import Group from "./Group";
|
import Group from "./Group";
|
||||||
import GroupUser from "./GroupUser";
|
import GroupUser from "./GroupUser";
|
||||||
import Integration from "./Integration";
|
import Integration from "./Integration";
|
||||||
|
import IntegrationAuthentication from "./IntegrationAuthentication";
|
||||||
import Notification from "./Notification";
|
import Notification from "./Notification";
|
||||||
import NotificationSetting from "./NotificationSetting";
|
import NotificationSetting from "./NotificationSetting";
|
||||||
import Revision from "./Revision";
|
import Revision from "./Revision";
|
||||||
@ -26,7 +26,6 @@ import View from "./View";
|
|||||||
const models = {
|
const models = {
|
||||||
ApiKey,
|
ApiKey,
|
||||||
Attachment,
|
Attachment,
|
||||||
Authentication,
|
|
||||||
AuthenticationProvider,
|
AuthenticationProvider,
|
||||||
Backlink,
|
Backlink,
|
||||||
Collection,
|
Collection,
|
||||||
@ -37,6 +36,7 @@ const models = {
|
|||||||
Group,
|
Group,
|
||||||
GroupUser,
|
GroupUser,
|
||||||
Integration,
|
Integration,
|
||||||
|
IntegrationAuthentication,
|
||||||
Notification,
|
Notification,
|
||||||
NotificationSetting,
|
NotificationSetting,
|
||||||
Revision,
|
Revision,
|
||||||
@ -59,7 +59,6 @@ Object.keys(models).forEach((modelName) => {
|
|||||||
export {
|
export {
|
||||||
ApiKey,
|
ApiKey,
|
||||||
Attachment,
|
Attachment,
|
||||||
Authentication,
|
|
||||||
AuthenticationProvider,
|
AuthenticationProvider,
|
||||||
Backlink,
|
Backlink,
|
||||||
Collection,
|
Collection,
|
||||||
@ -70,6 +69,7 @@ export {
|
|||||||
Group,
|
Group,
|
||||||
GroupUser,
|
GroupUser,
|
||||||
Integration,
|
Integration,
|
||||||
|
IntegrationAuthentication,
|
||||||
Notification,
|
Notification,
|
||||||
NotificationSetting,
|
NotificationSetting,
|
||||||
Revision,
|
Revision,
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
Group,
|
Group,
|
||||||
GroupUser,
|
GroupUser,
|
||||||
Attachment,
|
Attachment,
|
||||||
Authentication,
|
IntegrationAuthentication,
|
||||||
Integration,
|
Integration,
|
||||||
AuthenticationProvider,
|
AuthenticationProvider,
|
||||||
} from "../models";
|
} from "../models";
|
||||||
@ -123,7 +123,7 @@ export async function buildIntegration(overrides: Object = {}) {
|
|||||||
|
|
||||||
const user = await buildUser({ teamId: overrides.teamId });
|
const user = await buildUser({ teamId: overrides.teamId });
|
||||||
|
|
||||||
const authentication = await Authentication.create({
|
const authentication = await IntegrationAuthentication.create({
|
||||||
service: "slack",
|
service: "slack",
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
|
Reference in New Issue
Block a user