Redirect to login instead of 401. Don't launch with RunAs for non-admins.

This commit is contained in:
Jared Goodwin 2020-05-07 07:28:26 -07:00
parent b17267ce2c
commit ca387a5ac9
2 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,17 @@
function Is-Administrator() {
$Identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$Principal = New-Object System.Security.Principal.WindowsPrincipal -ArgumentList $Identity
return $Principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls13
[System.IO.Directory]::CreateDirectory("$env:AppData\Remotely")
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "$env:AppData\Remotely\dotnet-install.ps1" -UseBasicParsing
&"$env:AppData\Remotely\dotnet-install.ps1" -Runtime dotnet
&"$env:AppData\Remotely\dotnet-install.ps1" -Runtime windowsdesktop
Start-Process -FilePath "dotnet.exe" -ArgumentList "$PSScriptRoot\Remotely_Desktop.dll" -WindowStyle Hidden -Verb RunAs
if (Is-Administrator) {
Start-Process -FilePath "dotnet.exe" -ArgumentList "$PSScriptRoot\Remotely_Desktop.dll" -WindowStyle Hidden -Verb RunAs
}
else {
Start-Process -FilePath "dotnet.exe" -ArgumentList "$PSScriptRoot\Remotely_Desktop.dll" -WindowStyle Hidden
}

View File

@ -57,7 +57,7 @@ namespace Remotely.Server.Attributes
return;
}
context.Result = new UnauthorizedResult();
context.Result = new RedirectToPageResult("/Account/Login", new { area = "Identity" });
}
}
}