Skip to content

Commit 8434a22

Browse files
Merge pull request #58 from Purdue-ACM-SIGAPP/revert-56-DotNet-Hide-URL
Revert "Dot net hide url"
2 parents e82ac26 + e903cfe commit 8434a22

File tree

5 files changed

+8
-41
lines changed

5 files changed

+8
-41
lines changed

Controllers/EventsController.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Microsoft.AspNetCore.Authorization;
21
using Microsoft.AspNetCore.Mvc;
32
using SimpleWebAppReact.Entities;
43
using Microsoft.Extensions.Logging;
@@ -97,8 +96,6 @@ public async Task<IEnumerable<Events>> Get([FromQuery] string? eventName = null,
9796
/// <param name="events"></param>
9897
/// <returns></returns>
9998
[HttpPost]
100-
//roles that can edit events
101-
[Authorize(Roles ="RA, Club, Greek Life Officer")]
10299
public async Task<ActionResult> Post(Events events)
103100
{
104101
await _events.InsertOneAsync(events);
@@ -112,8 +109,6 @@ public async Task<ActionResult> Post(Events events)
112109
/// <param name="events"></param>
113110
/// <returns></returns>
114111
[HttpPut]
115-
//roles that can edit events
116-
[Authorize(Roles ="RA, Club, Greek Life Officer")]
117112
public async Task<ActionResult> Update(Events events)
118113
{
119114
var filter = Builders<Events>.Filter.Eq(x => x.Id, events.Id);
@@ -127,8 +122,6 @@ public async Task<ActionResult> Update(Events events)
127122
/// <param name="id"></param>
128123
/// <returns></returns>
129124
[HttpDelete("{id}")]
130-
//roles that can edit events
131-
[Authorize(Roles ="RA, Club, Greek Life Officer")]
132125
public async Task<ActionResult> Delete(string id)
133126
{
134127
var filter = Builders<Events>.Filter.Eq(x => x.Id, id);

Controllers/UserController.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.AspNetCore.Mvc;
22
using SimpleWebAppReact.Entities;
33
using Microsoft.Extensions.Logging;
4-
using MongoDB.Bson;
54
using MongoDB.Driver;
65
using SimpleWebAppReact.Services;
76

@@ -73,14 +72,13 @@ public async Task<IEnumerable<User>> Get([FromQuery] string? name = null, [FromQ
7372
[HttpGet("{id}")]
7473
public async Task<ActionResult<User?>> GetById(string id)
7574
{
76-
ObjectId objectId = new ObjectId(id);
7775
// Simple validation to check if the ID is not null
7876
if (string.IsNullOrEmpty(id))
7977
{
8078
return BadRequest("Invalid ID format.");
8179
}
8280

83-
var filter = Builders<User>.Filter.Eq(x => x.Id, objectId);
81+
var filter = Builders<User>.Filter.Eq(x => x.Id, id);
8482
var user = _users.Find(filter).FirstOrDefault();
8583
return user is not null ? Ok(user) : NotFound();
8684
}
@@ -119,8 +117,7 @@ public async Task<ActionResult> Update(User user)
119117
[HttpDelete("{id}")]
120118
public async Task<ActionResult> Delete(string id)
121119
{
122-
ObjectId objectId = new ObjectId(id);
123-
var filter = Builders<User>.Filter.Eq(x => x.Id, objectId);
120+
var filter = Builders<User>.Filter.Eq(x => x.Id, id);
124121
await _users.DeleteOneAsync(filter);
125122
return Ok();
126123
}

Entities/User.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
using AspNetCore.Identity.Mongo.Model;
2-
31
namespace SimpleWebAppReact.Entities;
42
using MongoDB.Bson;
53
using MongoDB.Bson.Serialization.Attributes;
64
/// <summary>
75
/// Class structure matches 1-1 with User Table in database
86
/// </summary>
9-
public class User : MongoUser
7+
public class User
108
{
11-
// [BsonId]
12-
// [BsonElement("_id"), BsonRepresentation(BsonType.ObjectId)]
13-
// public string? Id { get; set; }
9+
[BsonId]
10+
[BsonElement("_id"), BsonRepresentation(BsonType.ObjectId)]
11+
public string? Id { get; set; }
1412

1513
[BsonElement("name"), BsonRepresentation(BsonType.String)]
1614
public string? Name { get; set; }

Program.cs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
using System.Security.Claims;
2-
using AspNetCore.Identity.Mongo;
3-
using AspNetCore.Identity.Mongo.Model;
42
using Microsoft.AspNetCore.Authentication.JwtBearer;
53
using Microsoft.AspNetCore.Authorization;
64
using Microsoft.AspNetCore.Identity;
75
using Microsoft.IdentityModel.Tokens;
86
using Microsoft.OpenApi.Models;
97
using SimpleWebAppReact;
10-
using SimpleWebAppReact.Entities;
118
using SimpleWebAppReact.Services;
129

1310
var builder = WebApplication.CreateBuilder(args);
@@ -50,28 +47,12 @@
5047
});
5148
});
5249
builder.Services.AddSingleton<MongoDbService>();
53-
// Here, configure User
54-
var connectionString = builder.Configuration.GetConnectionString("DbConnection");
55-
var databaseName = builder.Configuration.GetConnectionString("DatabaseName");
56-
57-
// At the ConfigureServices section in Startup.cs
58-
builder.Services.AddIdentityMongoDbProvider<User, MongoRole>(identity =>
59-
{
60-
identity.Password.RequiredLength = 8;
61-
// other options
62-
},
63-
mongo =>
64-
{
65-
mongo.ConnectionString = connectionString;
66-
// other options
67-
});
68-
6950
builder.Services.AddHttpClient<BuildingOutlineService>();
7051
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
7152
.AddJwtBearer(options =>
7253
{
73-
options.Authority = builder.Configuration.GetConnectionString("opt_Authority");
74-
options.Audience = builder.Configuration.GetConnectionString("opt_audience");
54+
options.Authority = "https://dev-2gowyyl3kin685ua.us.auth0.com/";
55+
options.Audience = "http://localhost:5128";
7556
options.TokenValidationParameters = new TokenValidationParameters
7657
{
7758
NameClaimType = ClaimTypes.NameIdentifier,

SimpleWebAppReact.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="AspNetCore.Identity.Mongo" Version="9.0.1-rc1" />
1211
<PackageReference Include="Auth0.AspNetCore.Authentication" Version="1.4.1" />
1312
<PackageReference Include="dotenv.net" Version="3.2.1" />
1413
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
1514
<PackageReference Include="FuzzySharp" Version="2.0.2" />
1615
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
1716
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.33" />
18-
<PackageReference Include="MongoDB.AspNet.Identity" Version="1.0.5" />
1917
<PackageReference Include="MongoDB.Driver" Version="2.28.0" />
2018
<PackageReference Include="Moq" Version="4.20.70" />
2119
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

0 commit comments

Comments
 (0)