Skip to content

Commit

Permalink
getUserAndAccountFromSesstion -> getUserAndAccountFromSession (NangoH…
Browse files Browse the repository at this point in the history
  • Loading branch information
khaliqgant committed Apr 19, 2023
1 parent 0f19dc6 commit a220f0e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions packages/server/lib/controllers/account.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Request, Response, NextFunction } from 'express';
import accountService from '../services/account.service.js';
import { getUserAndAccountFromSesstion, isCloud, getOauthCallbackUrl } from '../utils/utils.js';
import { getUserAndAccountFromSession, isCloud, getOauthCallbackUrl } from '../utils/utils.js';
import errorManager from '../utils/error.manager.js';

class AccountController {
async getAccount(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;

if (!isCloud()) {
account.callback_url = await getOauthCallbackUrl();
Expand All @@ -31,7 +31,7 @@ class AccountController {
return;
}

let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;

await accountService.editAccountCallbackUrl(req.body['callback_url'], account.id);
res.status(200).send();
Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import errorManager from '../utils/error.manager.js';
import accountService from '../services/account.service.js';
import util from 'util';
import analytics from '../utils/analytics.js';
import { isCloud, resetPasswordSecret, getBaseUrl, getUserAndAccountFromSesstion } from '../utils/utils.js';
import { isCloud, resetPasswordSecret, getBaseUrl, getUserAndAccountFromSession } from '../utils/utils.js';
import jwt from 'jsonwebtoken';
import Mailgun from 'mailgun.js';
import type { User } from '../models.js';
Expand All @@ -23,7 +23,7 @@ export interface WebUser {
class AuthController {
async signin(req: Request, res: Response, next: NextFunction) {
try {
let user = (await getUserAndAccountFromSesstion(req)).user;
let user = (await getUserAndAccountFromSession(req)).user;
let webUser: WebUser = {
id: user.id,
accountId: user.account_id,
Expand Down
12 changes: 6 additions & 6 deletions packages/server/lib/controllers/config.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { NextFunction, Request, Response } from 'express';
import configService from '../services/config.service.js';
import type { ProviderConfig } from '../models.js';
import analytics from '../utils/analytics.js';
import { getAccount, getUserAndAccountFromSesstion, parseConnectionConfigParamsFromTemplate } from '../utils/utils.js';
import { getAccount, getUserAndAccountFromSession, parseConnectionConfigParamsFromTemplate } from '../utils/utils.js';
import errorManager from '../utils/error.manager.js';
import connectionService from '../services/connection.service.js';
import { NangoError } from '../utils/error.js';
Expand All @@ -14,7 +14,7 @@ class ConfigController {

async listProviderConfigsWeb(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;

let configs = await configService.listProviderConfigs(account.id);

Expand Down Expand Up @@ -47,7 +47,7 @@ class ConfigController {

async createProviderConfigWeb(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;

if (req.body == null) {
errorManager.errRes(res, 'missing_body');
Expand Down Expand Up @@ -121,7 +121,7 @@ class ConfigController {

async editProviderConfigWeb(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;

if (req.body == null) {
errorManager.errRes(res, 'missing_body');
Expand Down Expand Up @@ -176,7 +176,7 @@ class ConfigController {

async deleteProviderConfigWeb(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;
let providerConfigKey = req.params['providerConfigKey'] as string;

if (providerConfigKey == null) {
Expand All @@ -194,7 +194,7 @@ class ConfigController {

async getProviderConfigWeb(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;
let providerConfigKey = req.params['providerConfigKey'] as string;

if (providerConfigKey == null) {
Expand Down
8 changes: 4 additions & 4 deletions packages/server/lib/controllers/connection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { NextFunction } from 'express';
import configService from '../services/config.service.js';
import { ProviderConfig, ProviderTemplate, Connection, ProviderAuthModes, ProviderTemplateOAuth2 } from '../models.js';
import analytics from '../utils/analytics.js';
import { getAccount, getUserAndAccountFromSesstion } from '../utils/utils.js';
import { getAccount, getUserAndAccountFromSession } from '../utils/utils.js';
import errorManager from '../utils/error.manager.js';

class ConnectionController {
Expand All @@ -14,7 +14,7 @@ class ConnectionController {

async getConnectionWeb(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;

let connectionId = req.params['connectionId'] as string;
let providerConfigKey = req.query['provider_config_key'] as string;
Expand Down Expand Up @@ -74,7 +74,7 @@ class ConnectionController {

async getConnectionsWeb(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;

let connections = await connectionService.listConnections(account.id);

Expand Down Expand Up @@ -111,7 +111,7 @@ class ConnectionController {

async deleteConnectionWeb(req: Request, res: Response, next: NextFunction) {
try {
let account = (await getUserAndAccountFromSesstion(req)).account;
let account = (await getUserAndAccountFromSession(req)).account;
let connectionId = req.params['connectionId'] as string;
let providerConfigKey = req.query['provider_config_key'] as string;

Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/controllers/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getUserAndAccountFromSesstion } from '../utils/utils.js';
import { getUserAndAccountFromSession } from '../utils/utils.js';
import type { Request, Response, NextFunction } from 'express';

class UserController {
async getUser(req: Request, res: Response, next: NextFunction) {
try {
let user = (await getUserAndAccountFromSesstion(req)).user;
let user = (await getUserAndAccountFromSession(req)).user;

res.status(200).send({
user: {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function isUserAuthenticated(req: Request): boolean {
return req.isAuthenticated() && req.user != null && req.user.id != null;
}

export async function getUserAndAccountFromSesstion(req: Request): Promise<{ user: User; account: Account }> {
export async function getUserAndAccountFromSession(req: Request): Promise<{ user: User; account: Account }> {
let sessionUser = req.user;

if (sessionUser == null) {
Expand Down

0 comments on commit a220f0e

Please sign in to comment.