Activities of "berkansasmaz"

Hi Albert :)

The password for Redis can be given via appsettings.json as in the picture below.

I haven't tried it as environment variables because if it reads from appsettings.json, we can be sure that it will read it as environment variables as well. For more information you can check here.

Hi,

In our previous conversations, you did not say that you want to do it on the public web side.

As a solution: Compare the MyProjectNameWebPublicModule in the MyProjectName.Web.Public project with the MyProjectNameIdentityServerModule in the MyProjectName.IdentityServer project and add the missing ones to the MyProjectNameWebPublicModule. As a result, you will reach the view in the image below.

Please let us know if it works after you try it.

Hi,

To do this, you create a common Web project (eg MyProjectName.Web.Common) and move all the information you will use in common, such as MyProjectNameMenuContributor, there. Both projects must have a reference here.

There are two difficulties here:

  1. For example, you must depend on GroupName for AuditLogs menu and some projects for required permissions, if any, so you can remove them from MyProjectName.Web to not reference them in two different places because those dependencies will already come with MyProjectName.Web.Common.

  2. You must get the full URL information for the menus, you can do this in 3 ways. a. Hard coded :( b. By creating a class that holds your URL information to the MyProjectName.Domain.Shared project.

    public static class MyProjectNameExternalUrls
    {
#if DEBUG
        public const string MyProjectNameAccount = "https://localhost:44333";
        public const string MyProjectNameWeb = "https://localhost:44325";
#else
        public const string MyProjectNameAccount = "https://account.mydomain.io";
        public const string MyProjectNameWeb = "https://mydomain.io";
#endif
    }

The advantage of this is that the menu urls change according to the environment, and the disadvantage is that it duplicates the URL information. Because this information is already available in appsettings.json.

c. You can create the structure that suits your needs by using the Options pattern.

In my opinion, the shortest and acceptable one is to create a class like MyProjectNameExternalUrls, but if you have the time, the best solution is to design the necessary structure using the options pattern.

I hope the information I have provided will be of use to you :)

Thank you for reporting the issue.

I tested this situation and faced a similar situation.

I'm opening an internal issue about this because the problem only exists in the Lepton theme. By the way, the ticket refunded.

Hi,

If you delete the cookies belonging to the application, I think it will be fixed.

But if it doesn't fix, can you write your detailed steps so that I can reproduce the error?

Additional info: If it was fixed by deleting the cookies, you probably had a different application for the same port before, or you deleted and recreated the database. In this case, it is normal to get this error because the id of the tenant in the cookie is still the same.

Yes, that's right, for someone who currently has a blazor-server application, the audit-logs page looks like the picture below, which is not very meaningful.

As a result of my short research on the subject, I encountered many arguments saying that the request path cannot be taken, but I am opening an internal issue for further investigation.

By the way, I'm closing the issue, however, I'll reply it here with the details when we reach a conclusion.

Answer

Hi,

I will share step by step to help your question more. After doing all this, our application will show the menu or not depending on whether the user is logged in or not. Here are the minimum codes to meet these requirements:


Run the following command under the Angular folder: yarn ng generate component my-menu


Then, open the app.component.ts and execute the add method of ReplaceableComponentsService to replace your component with an ABP component as shown below:


It remains only to shape my-menu.component.html and my-menu.component.ts according to the requirements.

Here is my-menu.component.html:

<header>
    <div *ngIf="!hasLoggedIn">
        <div #navbarBrand>
            <abp-logo></abp-logo>
          </div>
          <abp-navbar-mobile></abp-navbar-mobile>
          <abp-navbar></abp-navbar>
          <abp-sidebar></abp-sidebar>
    </div>
    <div *ngIf="hasLoggedIn">
        <h1>Test QA 1664</h1>
        <app-root></app-root>
    </div>
</header>

my-menu.component.ts

import { Component, OnInit } from '@angular/core';
import { OAuthService } from 'angular-oauth2-oidc';
import { AuthService } from '@abp/ng.core';

@Component({
  selector: 'app-my-menu',
  templateUrl: './my-menu.component.html',
  styleUrls: ['./my-menu.component.scss']
})
export class MyMenuComponent implements OnInit {
  get hasLoggedIn(): boolean {
    return this.oAuthService.hasValidAccessToken();
  }

  constructor(private oAuthService: OAuthService, private authService: AuthService) {}

  login() {
    this.authService.navigateToLogin();
  }

  ngOnInit() {}  
}

Please let us know if it works after you try it.

Also some links that I think might be useful: https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement https://docs.abp.io/en/abp/latest/UI/Angular/Modifying-the-Menu

  • Create CustomLoginModel.cs file in the same folder (Pages\Account) CustomLoginModel.cs
using System;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using Owl.reCAPTCHA;
using Volo.Abp.Account.ExternalProviders;
using Volo.Abp.Account.Public.Web;
using Volo.Abp.Account.Public.Web.Pages.Account;
using Volo.Abp.Account.Security.Recaptcha;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Security.Claims;

namespace TestQABZ.Pages.Account
{
    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(LoginModel))]
    public class CustomLoginModel : LoginModel
    {
        public CustomLoginModel(
            IAuthenticationSchemeProvider schemeProvider, 
            IOptions<AbpAccountOptions> accountOptions, 
            IAbpRecaptchaValidatorFactory recaptchaValidatorFactory, 
            IAccountExternalProviderAppService accountExternalProviderAppService, 
            ICurrentPrincipalAccessor currentPrincipalAccessor, 
            IOptions<IdentityOptions> identityOptions, 
            IOptionsSnapshot<reCAPTCHAOptions> reCaptchaOptions) : 
            base(schemeProvider, 
                accountOptions, 
                recaptchaValidatorFactory, 
                accountExternalProviderAppService, 
                currentPrincipalAccessor, 
                identityOptions, 
                reCaptchaOptions)
        {
            Console.WriteLine("Test QA");
        }
    }
}
  • Add a CSS to play with the existing styles. Create Login.css in the same folder (Pages\Account) Login.css
.container {
    background-color: #d0d08c;
}

.card {
    background: #bccce4;
}

  • Add a JS to write JavaScript. Create Login.js in the same folder (Pages\Account) Login.js
alert('login page loaded.');

When we do all these, you will have a structure similar to the one below:

Once it's up and running, you can make any changes you want, but if you encounter a problem, please let us know again.

First of all it will be CustomLoginModel.cs not CustomLoginModel.cshtml :(

So it's my fault that you're confused, I hope I can make up for it :)

If we have to go step by step 👇

  • Create a new Login.cshtml under Pages\Account folder

Login.cshtml

@page
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Options
@using Owl.reCAPTCHA
@using Volo.Abp.Account.Localization
@using Volo.Abp.Account.Public.Web.Security.Recaptcha
@using Volo.Abp.Account.Settings
@using Volo.Abp.Settings
@model Volo.Abp.Account.Public.Web.Pages.Account.LoginModel
@inject IHtmlLocalizer<AccountResource> L
@inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout
@inject ISettingProvider SettingProvider
@{
    PageLayout.Content.Title = L["Login"].Value;
    var reCaptchaVersion = await SettingProvider.GetAsync<int>(AccountSettingNames.Captcha.Version);
    if (Model.UseCaptcha)
    {
        await Model.ReCaptchaOptions.SetAsync(reCaptchaVersion == 3 ? reCAPTCHAConsts.V3 :reCAPTCHAConsts.V2);
    }

}

@section scripts
{
    <abp-script src="/Pages/Account/Login.js" />
    @if (Model.UseCaptcha)
    {
        if (reCaptchaVersion == 3)
        {
            <recaptcha-script-v3/>
            <recaptcha-script-v3-js action="login" callback="(function(){$('#@RecaptchaValidatorBase.RecaptchaResponseKey').val(token)})"/>
        }
        else
        {
            <recaptcha-script-v2/>
        }
    }
}

@section styles
{
    <abp-style src="/Pages/Account/Login.css" />
}

@if (Model.IsLinkLogin)
{
    <abp-alert alert-type="Warning">
        @L["LinkAccountWarning", Url.PageLink()]
    </abp-alert>
}

<div class="account-module-form">
    @if (Model.EnableLocalLogin)
    {
        <form method="post">
            @if (Model.UseCaptcha)
            {
                <input type="hidden" name="@RecaptchaValidatorBase.RecaptchaResponseKey" id="@RecaptchaValidatorBase.RecaptchaResponseKey"/>
            }
            <p>Test QA Question: 1668</p>
            <abp-input asp-for="LoginInput.UserNameOrEmailAddress" required-symbol="false"/>
            <abp-input asp-for="LoginInput.Password" required-symbol="false"/>
            <abp-row>
                <abp-column>
                    <abp-input asp-for="LoginInput.RememberMe" class="mb-4"/>
                </abp-column>
                <abp-column class="text-right">
                    <a href="@Url.Page("./ForgotPassword", new { returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash })">@L["ForgotPassword"]</a>
                </abp-column>
            </abp-row>

            @if (reCaptchaVersion == 2)
            {
                <recaptcha-div-v2 callback="(function(){$('#@RecaptchaValidatorBase.RecaptchaResponseKey').val(token)})" />
            }

            <abp-button button-type="Primary" size="Block" type="submit" class="mt-2 mb-3" name="Action" value="Login">@L["Login"]</abp-button>
            @if (Model.ShowCancelButton)
            {
                <abp-button button-type="Secondary" size="Block" type="submit" formnovalidate="formnovalidate" class="mt-2 mb-3" name="Action" value="Cancel">@L["Cancel"]</abp-button>
            }
        </form>
        if (Model.IsSelfRegistrationEnabled)
        {
            @L["NotAMemberYet"]
            <a href="@Url.Page("./Register", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})">@L["Register"]</a>
        }
    }

    @if (Model.VisibleExternalProviders.Any())
    {
        <hr/>
        @L["OrSignInWith"]<br/>
        <form asp-page="./Login" asp-page-handler="ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" asp-route-returnUrlHash="@Model.ReturnUrlHash" method="post">
            @foreach (var provider in Model.VisibleExternalProviders)
            {
                <button
                    type="submit"
                    class="mt-2 mr-2 btn btn-outline-primary btn-sm"
                    name="provider"
                    value="@provider.AuthenticationScheme"
                    data-busy-text="@L["ProcessingWithThreeDot"]">
                    @if (provider.Icon != null)
                    {
                        <i class="@provider.Icon"></i>
                    }
                    <span>@provider.DisplayName</span>
                </button>
            }
        </form>
    }

    @if (!Model.EnableLocalLogin && !Model.VisibleExternalProviders.Any())
    {
        <div class="alert alert-warning">
            <strong>Invalid login request</strong>
            There are no login schemes configured for this client.
        </div>
    }
</div>

Then... 👇👇👇

Hi,

I'm assuming you have created the Account folder in the Pages folder of the MyProjectName.IdentityServer project :)

CustomLoginModel.cs in Account folder

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(LoginModel))]
    public class CustomLoginModel : LoginModel
    {
        public CustomLoginModel(
            IAuthenticationSchemeProvider schemeProvider, 
            IOptions<AbpAccountOptions> accountOptions, 
            IAbpRecaptchaValidatorFactory recaptchaValidatorFactory, 
            IAccountExternalProviderAppService accountExternalProviderAppService, 
            ICurrentPrincipalAccessor currentPrincipalAccessor, 
            IOptions<IdentityOptions> identityOptions, 
            IOptionsSnapshot<reCAPTCHAOptions> reCaptchaOptions) : 
            base(schemeProvider, 
                accountOptions, 
                recaptchaValidatorFactory, 
                accountExternalProviderAppService, 
                currentPrincipalAccessor, 
                identityOptions, 
                reCaptchaOptions)
        {
            Console.WriteLine("Test QA Question");
        }
    }

Please let us know if it works after you try it.

Zobrazeno od 291 do 300 z celkem 318 záznamů
Made with ❤️ on ABP v8.2.0-preview Updated on března 25, 2024, 15:11