chore: Rename Authentication -> IntegrationAuthentication (#2091)

This commit is contained in:
Tom Moor 2021-04-27 18:42:45 -07:00 committed by GitHub
parent 829cc14d36
commit b89f4c36f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 18 deletions

View File

@ -5,13 +5,13 @@ import { AuthenticationError, InvalidRequestError } from "../errors";
import {
UserAuthentication,
AuthenticationProvider,
Authentication,
Document,
User,
Team,
Collection,
SearchQuery,
Integration,
IntegrationAuthentication,
} from "../models";
import { presentSlackAttachment } from "../presenters";
import * as Slack from "../slack";
@ -38,7 +38,7 @@ router.post("hooks.unfurl", async (ctx) => {
});
if (!user) return;
const auth = await Authentication.findOne({
const auth = await IntegrationAuthentication.findOne({
where: { service: "slack", teamId: user.teamId },
});
if (!auth) return;

View File

@ -1,7 +1,7 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server";
import app from "../app";
import { Authentication, SearchQuery } from "../models";
import { IntegrationAuthentication, SearchQuery } from "../models";
import * as Slack from "../slack";
import { buildDocument, buildIntegration } from "../test/factories";
import { flushdb, seed } from "../test/support";
@ -18,7 +18,7 @@ jest.mock("../slack", () => ({
describe("#hooks.unfurl", () => {
it("should return documents", async () => {
const { user, document } = await seed();
await Authentication.create({
await IntegrationAuthentication.create({
service: "slack",
userId: user.id,
teamId: user.teamId,

View File

@ -6,7 +6,12 @@ import accountProvisioner from "../../commands/accountProvisioner";
import env from "../../env";
import auth from "../../middlewares/authentication";
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 { StateStore } from "../../utils/passport";
@ -113,7 +118,7 @@ if (SLACK_CLIENT_ID) {
const endpoint = `${process.env.URL || ""}/auth/slack.commands`;
const data = await Slack.oauthAccess(code, endpoint);
const authentication = await Authentication.create({
const authentication = await IntegrationAuthentication.create({
service: "slack",
userId: user.id,
teamId: user.teamId,
@ -168,7 +173,7 @@ if (SLACK_CLIENT_ID) {
const endpoint = `${process.env.URL || ""}/auth/slack.post`;
const data = await Slack.oauthAccess(code, endpoint);
const authentication = await Authentication.create({
const authentication = await IntegrationAuthentication.create({
service: "slack",
userId: user.id,
teamId: user.teamId,

View File

@ -26,7 +26,7 @@ Integration.associate = (models) => {
as: "collection",
foreignKey: "collectionId",
});
Integration.belongsTo(models.Authentication, {
Integration.belongsTo(models.IntegrationAuthentication, {
as: "authentication",
foreignKey: "authenticationId",
});

View File

@ -1,7 +1,7 @@
// @flow
import { DataTypes, sequelize, encryptedFields } from "../sequelize";
const Authentication = sequelize.define("authentication", {
const IntegrationAuthentication = sequelize.define("authentication", {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
@ -12,15 +12,15 @@ const Authentication = sequelize.define("authentication", {
token: encryptedFields().vault("token"),
});
Authentication.associate = (models) => {
Authentication.belongsTo(models.User, {
IntegrationAuthentication.associate = (models) => {
IntegrationAuthentication.belongsTo(models.User, {
as: "user",
foreignKey: "userId",
});
Authentication.belongsTo(models.Team, {
IntegrationAuthentication.belongsTo(models.Team, {
as: "team",
foreignKey: "teamId",
});
};
export default Authentication;
export default IntegrationAuthentication;

View File

@ -1,7 +1,6 @@
// @flow
import ApiKey from "./ApiKey";
import Attachment from "./Attachment";
import Authentication from "./Authentication";
import AuthenticationProvider from "./AuthenticationProvider";
import Backlink from "./Backlink";
import Collection from "./Collection";
@ -12,6 +11,7 @@ import Event from "./Event";
import Group from "./Group";
import GroupUser from "./GroupUser";
import Integration from "./Integration";
import IntegrationAuthentication from "./IntegrationAuthentication";
import Notification from "./Notification";
import NotificationSetting from "./NotificationSetting";
import Revision from "./Revision";
@ -26,7 +26,6 @@ import View from "./View";
const models = {
ApiKey,
Attachment,
Authentication,
AuthenticationProvider,
Backlink,
Collection,
@ -37,6 +36,7 @@ const models = {
Group,
GroupUser,
Integration,
IntegrationAuthentication,
Notification,
NotificationSetting,
Revision,
@ -59,7 +59,6 @@ Object.keys(models).forEach((modelName) => {
export {
ApiKey,
Attachment,
Authentication,
AuthenticationProvider,
Backlink,
Collection,
@ -70,6 +69,7 @@ export {
Group,
GroupUser,
Integration,
IntegrationAuthentication,
Notification,
NotificationSetting,
Revision,

View File

@ -10,7 +10,7 @@ import {
Group,
GroupUser,
Attachment,
Authentication,
IntegrationAuthentication,
Integration,
AuthenticationProvider,
} from "../models";
@ -123,7 +123,7 @@ export async function buildIntegration(overrides: Object = {}) {
const user = await buildUser({ teamId: overrides.teamId });
const authentication = await Authentication.create({
const authentication = await IntegrationAuthentication.create({
service: "slack",
userId: user.id,
teamId: user.teamId,