This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getConnection, Repository } from "typeorm"; | |
import { User } from "../entity/User"; | |
export default class UserService { | |
private userRepository: Repository<User>; | |
constructor() {} | |
private getUserRepository(): Repository<User> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from "express"; | |
import setupTypeORM from "./setuptypeorm"; | |
var app = express(); | |
// Creates the try connect loop. | |
setupTypeORM(); | |
app.use(...); | |
// Start other middleware and routes... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createConnection, Connection, getConnection } from "typeorm"; | |
import { CONNECTION_STRING } from "./config"; | |
const setupTypeORM = async () => { | |
let connection: any = null; | |
while (connection == undefined || !connection.isConnected) | |
{ | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as express from "express"; | |
import ...; | |
import { createConnection } from "typeorm"; | |
const app = express(); | |
createConnection().then((connection) => { | |
app.use(...); | |
// Start other middleware and routes... | |
app.use(...); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
[Route("logout")] | |
public IActionResult Logout() | |
{ | |
HttpContext.User = new ClaimsPrincipal(); | |
RefreshCSRFToken(); | |
HttpContext.Response.Cookies.Delete("jwt"); | |
return Ok(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class JwtCookieMiddleware | |
{ | |
/// <summary> | |
/// Checks the jwt cookie and sets the user for the application. | |
/// </summary> | |
/// <param name="app">App builder reference.</param> | |
/// <param name="antiforgery">Reference to the antiforgery service.</param> | |
/// <param name="key">The key to decrypt the token.</param> | |
/// <param name="autoRefresh">Creates a new token if the token is half past expiration time (and still valid).</param> | |
/// <param name="cookieName">Name of the cookie where the jwt is (defaults to jwt).</param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly UserService _userService; | |
private readonly IAntiforgery _antiforgery; | |
public UserApiController(UserService userService, | |
IAntiforgery antiforgery) | |
{ | |
_userService = userService; | |
_antiforgery = antiforgery; | |
} |
NewerOlder