-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add models from other projects [Regression] (#1718) * finding missing workspace files * using models from different projects enabled. * cleaning up more. * updated Versions.props * not adding/forcing Account.Logout.cshtml if blazor project already adds it. (#1721) * Adding #nullable disable to scaffolding templates (#1723) * checking for nullable msbuild property and adding #nullable disable to tempaltes * added #nulalble disable logic for NewLocalDbContext * updated macOS image * fixed mistake with azure images * updating Versions.MSIdentity.props to 1.0.1 * Enable Microsoft Graph option for Blazor Server (#1719) Enable Microsoft Graph option for Blazor Server, add .razor modification functionality Co-authored-by: zahalzel <75647613+zahalzel@users.noreply.github.com>
- Loading branch information
1 parent
abb901a
commit 4e8a252
Showing
8 changed files
with
825 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...ng/Microsoft.DotNet.MSIdentity/CodeReaderWriter/CodeFiles/Blazor/Server/ShowProfile.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
@page "/showprofile" | ||
|
||
@using Microsoft.Identity.Web | ||
@using Microsoft.Graph | ||
@inject Microsoft.Graph.GraphServiceClient GraphServiceClient | ||
@inject MicrosoftIdentityConsentAndConditionalAccessHandler ConsentHandler | ||
|
||
<h1>Me</h1> | ||
|
||
<p>This component demonstrates fetching data from a service.</p> | ||
|
||
@if (user == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table table-striped table-condensed" style="font-family: monospace"> | ||
<tr> | ||
<th>Property</th> | ||
<th>Value</th> | ||
</tr> | ||
<tr> | ||
<td>Name</td> | ||
<td>@user.DisplayName</td> | ||
</tr> | ||
<tr> | ||
<td>Photo</td> | ||
<td> | ||
@{ | ||
if (photo != null) | ||
{ | ||
<img style="margin: 5px 0; width: 150px" src="data:image/jpeg;base64, @photo" /> | ||
} | ||
else | ||
{ | ||
<h3>NO PHOTO</h3> | ||
<p>Check user profile in Azure Active Directory to add a photo.</p> | ||
} | ||
} | ||
</td> | ||
</tr> | ||
</table> | ||
} | ||
|
||
@code { | ||
User user; | ||
string photo; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
try | ||
{ | ||
user = await GraphServiceClient.Me.Request().GetAsync(); | ||
photo = await GetPhoto(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
ConsentHandler.HandleException(ex); | ||
} | ||
} | ||
|
||
protected async Task<string> GetPhoto() | ||
{ | ||
string photo; | ||
|
||
try | ||
{ | ||
using (var photoStream = await GraphServiceClient.Me.Photo.Content.Request().GetAsync()) | ||
{ | ||
byte[] photoByte = ((System.IO.MemoryStream)photoStream).ToArray(); | ||
photo = Convert.ToBase64String(photoByte); | ||
this.StateHasChanged(); | ||
} | ||
|
||
} | ||
catch (Exception) | ||
{ | ||
photo = null; | ||
} | ||
return photo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.