Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions kommande-access-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
WORKDIR /src

COPY *.csproj ./
COPY kommande-access-backend.csproj ./
RUN dotnet restore

COPY . .
RUN dotnet publish -c Release -o /out
COPY . ./
RUN dotnet publish -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /out .

EXPOSE 5031
COPY --from=build /app .
COPY products.db /app/products.db

EXPOSE 5000

ENTRYPOINT ["dotnet", "kommande-access-backend.dll"]
CMD ["bash", "-c", "dotnet kommande-access-backend.dll && dotnet ef database update"]
Binary file modified kommande-access-backend/products.db
Binary file not shown.
22 changes: 22 additions & 0 deletions kommande-access-gui/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:18 AS builder

WORKDIR /app

COPY package.json yarn.lock ./
RUN yarn install

COPY . .
RUN yarn build

FROM node:18-alpine AS runner

WORKDIR /app

COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./

EXPOSE 3000

CMD ["yarn", "start"]
Binary file added kommande-access-gui/public/favicon.ico
Binary file not shown.
47 changes: 47 additions & 0 deletions kommande-auth-backend/Controllers/UserController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using kommande_auth_backend.Models;
using kommande_auth_backend.Services;
using Microsoft.AspNetCore.Identity.Data;
using Microsoft.AspNetCore.Mvc;

namespace kommande_auth_backend.Controllers;

[ApiController]
[Route("[controller]")]
public class UserController(IUserService userService) : ControllerBase
{
[HttpGet("user")]
public async Task<IActionResult> GetUser([FromQuery] string userId)
{
var user = await userService.GetUser(userId);

return user is not null ? Ok(user) : NotFound("User not found");
}

[HttpPost("login")]
public async Task<IActionResult> Login([FromBody] LoginRequest request)
{
var user = await userService.Authenticate(request.Email, request.Password);
if (user == null)
{
return Unauthorized("Invalid request.");
}

return Ok(user);
}

[HttpPost("register")]
public async Task<IActionResult> Register([FromBody] User user)
{
User createdUser;
try
{
createdUser = await userService.Register(user);
}
catch (Exception e)
{
return BadRequest(e.Message);

}
return Created($"/user/{createdUser.Id}", createdUser);
}
}
19 changes: 19 additions & 0 deletions kommande-auth-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /src

COPY kommande-auth-backend.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:8.0

WORKDIR /app

COPY --from=build /app .

EXPOSE 5001

CMD ["dotnet", "kommande-auth-backend.dll"]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions kommande-auth-backend/Migrations/20241126153831_AddLoginRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace kommande_auth_backend.Migrations
{
/// <inheritdoc />
public partial class AddLoginRequest : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Password",
table: "Users");

migrationBuilder.AlterColumn<string>(
name: "PhoneNumber",
table: "Users",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");

migrationBuilder.AddColumn<string>(
name: "PasswordHash",
table: "Users",
type: "TEXT",
nullable: false,
defaultValue: "");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PasswordHash",
table: "Users");

migrationBuilder.AlterColumn<string>(
name: "PhoneNumber",
table: "Users",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);

migrationBuilder.AddColumn<string>(
name: "Password",
table: "Users",
type: "TEXT",
nullable: true);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace kommande_auth_backend.Migrations
{
/// <inheritdoc />
public partial class AddLoginRequest2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{

}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{

}
}
}
Loading
Loading