Added EnvelopeReceiverService to web client application.
This commit is contained in:
parent
c0a6103eb2
commit
cc3f6efbd7
@ -2,7 +2,6 @@
|
||||
using DigitalData.Core.DTO;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts
|
||||
{
|
||||
|
||||
@ -74,7 +74,10 @@
|
||||
"buildTarget": "envelope-generator-ui:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
"defaultConfiguration": "development",
|
||||
"options": {
|
||||
"proxyConfig": "src/proxy.conf.json"
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { LoginComponent } from './components/login/login.component';
|
||||
import {EnvelopeTableComponent} from '../app/components/envelope-table/envelope-table.component'
|
||||
import {HomeComponent} from '../app/components/home/home.component'
|
||||
export const routes: Routes = [
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { EnvelopeReceiverService } from '../../services/envelope-receiver.service';
|
||||
import { error } from 'console';
|
||||
|
||||
@Component({
|
||||
selector: 'app-envelope-table',
|
||||
@ -8,5 +10,15 @@ import { Component } from '@angular/core';
|
||||
styleUrl: './envelope-table.component.scss'
|
||||
})
|
||||
export class EnvelopeTableComponent {
|
||||
|
||||
|
||||
constructor(private erService : EnvelopeReceiverService){
|
||||
erService.getEnvelopeReceiver().subscribe({
|
||||
next: (res) => {
|
||||
console.log(res)
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,10 +35,9 @@ export class LoginComponent {
|
||||
if (this.loginForm.valid) {
|
||||
this.authService.login(this.loginForm.value).subscribe({
|
||||
next: () => {
|
||||
this.router.navigate(['/envelope']); // Adjust to your protected route
|
||||
this.router.navigate(['/envelope']);
|
||||
},
|
||||
error: error => {
|
||||
// Handle login error
|
||||
console.error('Login failed', error);
|
||||
}
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@ import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { API_URL } from '../tokens/index';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EnvelopeReceiverService } from './envelope-receiver.service';
|
||||
|
||||
describe('EnvelopeReceiverService', () => {
|
||||
let service: EnvelopeReceiverService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(EnvelopeReceiverService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,24 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable, catchError } from 'rxjs';
|
||||
import { API_URL } from '../tokens/index';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class EnvelopeReceiverService {
|
||||
private url: string;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
const api_url = inject(API_URL);
|
||||
this.url = `${api_url}/envelopereceiver`;
|
||||
}
|
||||
|
||||
getEnvelopeReceiver(): Observable<any> {
|
||||
const headers = new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
});
|
||||
|
||||
return this.http.get<any>(this.url, { withCredentials: true , headers });
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>signFlow</title>
|
||||
<base href="/">
|
||||
<meta name="api-url" content="https://localhost:7174/api">
|
||||
<meta name="api-url" content="/api">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
{
|
||||
"/api": {
|
||||
"target": "https://localhost:7174",
|
||||
"secure": false,
|
||||
"changeOrigin": true
|
||||
}
|
||||
}
|
||||
@ -31,6 +31,7 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
||||
}
|
||||
|
||||
//TODO: When a user group is created for signFlow, add a process to check if the user is in this group (like "PM_USER")
|
||||
[AllowAnonymous]
|
||||
[HttpPost("login")]
|
||||
public async Task<IActionResult> Login([FromBody] LogInDto login)
|
||||
{
|
||||
@ -39,13 +40,13 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
||||
bool isValid = _dirSearchService.ValidateCredentials(login.Username, login.Password);
|
||||
|
||||
if (!isValid)
|
||||
return Unauthorized(Result.Fail().Message(_localizer[Key.UserNotFound]));
|
||||
return Unauthorized();
|
||||
|
||||
//find the user
|
||||
var uRes = await _userService.ReadByUsernameAsync(login.Username);
|
||||
if (!uRes.IsSuccess || uRes.Data is null)
|
||||
{
|
||||
return Unauthorized(uRes);
|
||||
return Forbid();
|
||||
}
|
||||
|
||||
UserReadDto user = uRes.Data;
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
using DigitalData.Core.API;
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class EnvelopeController : BasicCRUDControllerBase<IEnvelopeService, EnvelopeDto, Envelope, int>
|
||||
{
|
||||
public EnvelopeController(ILogger<EnvelopeController> logger, IEnvelopeService service) : base(logger, service)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,6 @@
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using System.DirectoryServices.Protocols;
|
||||
|
||||
namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
||||
{
|
||||
|
||||
@ -45,4 +45,31 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ClientApp\envelope-generator-ui\dist\envelope-generator-ui\browser\chunk-35PBLQEP.js">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ClientApp\envelope-generator-ui\dist\envelope-generator-ui\browser\chunk-IUSOII6E.js">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ClientApp\envelope-generator-ui\dist\envelope-generator-ui\browser\favicon.ico">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ClientApp\envelope-generator-ui\dist\envelope-generator-ui\browser\index.html">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ClientApp\envelope-generator-ui\dist\envelope-generator-ui\browser\login\index.html">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ClientApp\envelope-generator-ui\dist\envelope-generator-ui\browser\main-ZN7C4PGY.js">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ClientApp\envelope-generator-ui\dist\envelope-generator-ui\browser\polyfills-N6LQB2YD.js">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ClientApp\envelope-generator-ui\dist\envelope-generator-ui\browser\styles-S5ZWIC2V.css">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -36,7 +36,16 @@ var connStr = config.GetConnectionString("Default") ?? throw new InvalidOperatio
|
||||
builder.Services.AddDbContext<EGDbContext>(options => options.UseSqlServer(connStr));
|
||||
|
||||
// Authentication
|
||||
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
||||
if (builder.Environment.IsDevelopment())
|
||||
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
||||
.AddCookie(options =>
|
||||
{
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.LoginPath = "/api/auth/login";
|
||||
options.LogoutPath = "/api/auth/logout";
|
||||
});
|
||||
else
|
||||
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
||||
.AddCookie(options =>
|
||||
{
|
||||
options.Cookie.HttpOnly = true; // Makes the cookie inaccessible to client-side scripts for security
|
||||
|
||||
@ -4,12 +4,11 @@ using EnvelopeGenerator.Application.Contracts;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
||||
{
|
||||
public class TestEnvelopeReceiverController : TestControllerBase<IEnvelopeReceiverService, EnvelopeReceiverDto, EnvelopeReceiver, int>
|
||||
public class TestEnvelopeReceiverController : TestControllerBase<IEnvelopeReceiverService, EnvelopeReceiverDto, EnvelopeReceiver, object>
|
||||
{
|
||||
public TestEnvelopeReceiverController(ILogger<TestEnvelopeReceiverController> logger, IEnvelopeReceiverService service) : base(logger, service)
|
||||
{
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
using DigitalData.UserManager.Infrastructure.Repositories;
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using EnvelopeGenerator.Application.MappingProfiles;
|
||||
using EnvelopeGenerator.Application.Services;
|
||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
using EnvelopeGenerator.Infrastructure.Repositories;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
@ -11,7 +8,6 @@ using Quartz;
|
||||
using NLog.Web;
|
||||
using DigitalData.Core.API;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using DigitalData.UserManager.Application.MappingProfiles;
|
||||
using EnvelopeGenerator.Web.Models;
|
||||
using DigitalData.Core.DTO;
|
||||
using System.Text.Encodings.Web;
|
||||
@ -19,7 +15,6 @@ using Ganss.Xss;
|
||||
using Microsoft.Extensions.Options;
|
||||
using DigitalData.EmailProfilerDispatcher.Application;
|
||||
using EnvelopeGenerator.Application;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
|
||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
logger.Info("Logging initialized!");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user