Code Monkey home page Code Monkey logo

fairwayfinder's Introduction

FairwayFinder

Tech Stack/Prerequisites

Quick Setup

Execute this command docker compose up --build in the root of the project (where the compose.yml resides) and this will get a version running in docker setup. (NOTE: You will need SendGrid credentials provided by the SendGrid admin for certain features such as health checks and user invites to work properly on your machine.)

Local development

To start developing locally, please make sure you have the above prerequisites installed and ready to go.

Getting Started

NOTE: You will need SendGrid credentials provided by the SendGrid admin for certain features such as health checks and user invites to work properly on your machine.

In pgadmin, create a database called FairwayFinder

Open the solution in your editor of choice. You should see this project structure:

  • src
    • FairwayFinder.Core
    • FairwayFinder.Web
  • tests
    • FairwayFinder.Core.Tests

Enter into the FairwayFinder.Web project and go to Program.cs

At the bottom, you should see this code block. Replace the email, first name, and last name in this code block to be your own information. This will set up a local dev admin account.

async Task CreateRoles(IServiceProvider serviceProvider) {
    //initializing custom roles 
    var roleManager = serviceProvider.GetRequiredService<RoleManager<IdentityRole>>();
    var userManager = serviceProvider.GetRequiredService<UserManager<ApplicationUser>>();
    string[] roleNames = [Roles.Admin, Roles.User];

    foreach (var roleName in roleNames) {
        var roleExist = await roleManager.RoleExistsAsync(roleName);
        // ensure that the role does not exist
        if (!roleExist) {
            //create the roles and seed them to the database: 
            await roleManager.CreateAsync(new IdentityRole(roleName));
        }
    }

    // Here you create the super admin who will maintain the web app. This password will obviously be changed. 
    await AddAdminUser(userManager, "[email protected]", "password");
}

// This is used on an initial launch of the application.
async Task AddAdminUser(UserManager<ApplicationUser> userManager, string username, string password) {
    var user = await userManager.FindByEmailAsync(username);

    // check if the user exists
    if (user == null) {
        //Here you could create the super admin who will maintain the web app
        var seedUser = new ApplicationUser {
            UserName = username,
            Email = username,
            EmailConfirmed = true,
            FirstName = "George",
            LastName = "Bjork"
        };
        var createPowerUser = await userManager.CreateAsync(seedUser, password);
        if (createPowerUser.Succeeded) {
            //here we tie the new user to the role
            await userManager.AddToRoleAsync(seedUser, Roles.Admin);
        }
    }
}

Once down, open FairwayFinder.Web in your terminal and run this command,

dotnet ef database update

to run all pending migrations for your db. Refresh your db to see if the migrations ran. If they did, you should be able to run the application.

fairwayfinder's People

Contributors

georgebjork avatar georgeb-macula avatar

Watchers

 avatar

fairwayfinder's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.