Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Server.Models;
- namespace Server.Controllers
- {
- [Route ( "[controller]" )]
- public class PlayerController : Controller
- {
- private Player player;
- public PlayerController ( )
- {
- // When the controller starts, let's create a dummy player.
- player = new Player ( )
- {
- ID = Guid.NewGuid ( ).ToString ( ),
- Name = "Milan Egon Votrubec",
- Alias = "Vot",
- Level = Player.PlayerLevel.Godlike
- };
- }
- [ AllowAnonymous]
- [HttpPost ( "get" )]
- public IActionResult Post ( [FromBody] UsernamePassword item )
- {
- // Let's check to see whether the caller has supplied the correct credentials.
- if ( item?.Username != "user" || item?.Password != "pass" )
- return BadRequest ( "Bad username or password." );
- // At this point, we've successfully "Logged In". Let's return the player to the caller.
- return Ok ( player );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement