Recently while working on a Power Pages implementation for a client, I had the requirement to show the last time a user logged in on their profile page. I thought this would be easy to do as there is already a field on the contact record for "Last Successful Login" ( adx_identity_lastsuccessfullogin). This use to update when a user logged in, but it appears Microsoft has removed that automation.
While searching I came across a few different ways of achieving this task. One used application insights in Azure and another one used an HTTP endpoint setup in Power Automate. I thought, this needs to be simpler. What I came up with is to use Liquid with JavaScript to tell if a user is logged in or not. Then use the new Power Pages api to update the logged in users contact record to mark the last time they logged in.
Here is the approach I setup:
1) Make sure you turn on the api for contact in Site Settings.
1) Link to Microsoft Doc On How to turn on the api
2) Make sure you include "adx_identity_lastsuccessfullogin" in the list of fields to return.
2) I tested my process on the home page. On the home page add two JavaScript Functions. The first function (CheckIfUserJustLoggedIn) uses Liquid to tell if the user is logged in. If they are not, it deletes our value from session memory. If the user is logged in we check session memory to see if there is already a key in there with the date and time the user logged in. If there is, we don't do anything else. If there isn't then we create it and we update the contact record for the user via the Power Pages API. The second function is Microsoft's wrapper function that handles the Ajax call and handles the authentication piece to make sure the user is authorized to perform the option.
1: function CheckIfUserJustLoggedIn()
2: {
3: var sessionLastLogin = "sessionLastLogin";
4: var isLoggedIn = "{% if user %}true{% else %}false{% endif %}";
5: if (isLoggedIn == 'true')
6: {
7: var userId = "{{user.id}}";
8: userId = userId.replace('{', '').replace('}', '');
9: var lastLogin = sessionStorage.getItem(sessionLastLogin);
10: if (lastLogin == null)
11: {
12: var dateTimestamp = new Date();
13: sessionStorage.setItem(sessionLastLogin, dateTimestamp);
14: webapi.safeAjax({
15: type: "PATCH",
16: url: "/_api/contacts(" + userId + ")",
17: contentType: "application/json",
18: data: JSON.stringify({
19: "adx_identity_lastsuccessfullogin": dateTimestamp
20: }),
21: success: function (res) {
22: console.log(res);
23: }
24: });
25: }
26: }
27: else
28: {
29: sessionStorage.removeItem(sessionLastLogin);
30: }
31: }
1: (function(webapi, $){
2: function safeAjax(ajaxOptions) {
3: var deferredAjax = $.Deferred();
4: shell.getTokenDeferred().done(function (token) {
5: // add headers for AJAX
6: if (!ajaxOptions.headers) {
7: $.extend(ajaxOptions, {
8: headers: {
9: "__RequestVerificationToken": token
10: }
11: });
12: } else {
13: ajaxOptions.headers["__RequestVerificationToken"] = token;
14: }
15: $.ajax(ajaxOptions)
16: .done(function(data, textStatus, jqXHR) {
17: validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
18: }).fail(deferredAjax.reject); //AJAX
19: }).fail(function () {
20: deferredAjax.rejectWith(this, arguments); // on token failure pass the token AJAX and args
21: });
22: return deferredAjax.promise();
23: }
24: webapi.safeAjax = safeAjax;
25: })(window.webapi = window.webapi || {}, jQuery)
If you run into issues for permissions check your Power Pages Web Roles table and make sure the user has the correct permissions for the contact table.
The world of Chrome Hearts Matty Boy is full of color and meaning. The brand celebrates imperfection and creative expression.
ReplyDeleteUsers can search HMDD by disease name or by specific microRNA identifiers. The database interface provides an intuitive design that simplifies data exploration for both experts and students.
ReplyDeleteJapanese knives also stand out for their blade geometry. Unlike Western knives, which often feature a double-beveled edge, many traditional Japanese knives have a single-beveled edge, meaning they are sharpened on only one side. This design enables more precise cuts and is ideal for delicate slicing tasks, such as preparing sushi or sashimi. The asymmetry also contributes to the knife’s characteristic cutting feel.
ReplyDelete"The detailing on the back of the hoodie is what got me. Trapstar really puts effort into every piece they drop."
ReplyDeleteCorteiz emerged around 2017, when Clint began selling T-shirts and hoodies emblazoned with the now-iconic Alcatraz logo—a symbol representing freedom and breaking boundaries. Rather than relying on traditional retail strategies
ReplyDeleteLE LIS is a contemporary women’s fashion brand whose mission is to celebrate the vibrant spirit of today’s trendy young women. According to the brand’s “About Us” page, it seeks to empower women to express their individuality, feel confident, and turn heads with every outfit.
ReplyDeletefake gods often arose from superstition and ignorance. When natural phenomena like storms, droughts, or diseases struck, people personified them as deities to explain the unknown. Over time, some individuals manipulated these beliefs for personal gain
ReplyDeleteKurtka Trapstar to must-have tego sezonu 🔥 Widziałam już kilka influencerek, które ją noszą.
ReplyDeleteOver time, the meaning of “godspeed” has broadened beyond physical travel. It is now often used metaphorically to wish someone well as they embark on any significant undertaking—starting a new job, pursuing education, or beginning a new chapter in life.
ReplyDelete“What I love most about Asaali is that their clothes make me feel confident and classy without trying too hard. Minimal effort, maximum elegance!”
ReplyDeletefake gods have taken new forms. No longer confined to temples or shrines, they exist in the digital world, in celebrity culture, and even in corporate ideologies. Many people today unconsciously worship money, technology, or fame—believing these forces can bring ultimate happiness.
ReplyDeleteSp5der emphasises high‐quality fabrics: heavy cotton fleece blends, reinforced seams, and durability built for the urban environment.
ReplyDeleteThe Essentials hoodie has become a standout piece in Canada’s streetwear culture, representing both comfort and minimalism. Designed by Fear of God’s Jerry Lorenzo, the hoodie combines luxury aesthetics with everyday practicality, making it a staple for those who value both fashion and function.
ReplyDeleteLove how Sean John clothing celebrates individuality and confidence. You can feel the energy of hip-hop culture in every piece.
ReplyDeleteLattafa Perfumes was founded in 1982, born from a passion for creating perfumes that reflect the rich cultural heritage of Arabia.
ReplyDelete“Super cozy and the oversized fit is perfect for layering. Would love to see a zip-up version too!”
ReplyDeleteCodes expire, or may only apply to certain items (e.g., full-price items only). If a code doesn’t work, it may be expired or not eligible for the items in your cart. The example site explains this issue.
ReplyDeleteThese fabrics make the hoodie ideal for year-round wear, from chilly mornings to cozy evenings. The fabric’s breathable nature also ensures comfort during light physical activities or lounging at home. Many hoodies feature a fleece lining that adds an extra layer of warmth, especially in colder months.
ReplyDeleteFashion reps have honestly changed the game for people who love designer styles but don’t want to spend thousands. Some of the newer pieces are almost identical to retail — from the fabrics to the logos. It’s amazing how far the quality has come in just a few years.
ReplyDeleteSocial media has played a major role in the hoodie’s rise to fame. Influencers, models, and celebrities have been frequently spotted wearing Mr Winston, often styling it with other minimalist pieces or statement sneakers. The brand’s organic popularity on platforms like Instagram and TikTok has turned the hoodie into a symbol of relaxed sophistication. It’s now recognized globally, even though the brand remains deeply rooted in its Australian origins.
ReplyDeleteL’aspect environnemental occupe une place importante dans la stratégie de Davril Supply. Consciente des enjeux liés au développement durable, l’entreprise a mis en place plusieurs initiatives visant à réduire son empreinte écologique.
ReplyDeleteBluzy tej marki charakteryzują się minimalistycznym krojem i funkcjonalnymi detalami. Często posiadają charakterystyczną naszywkę z kompasem na lewym ramieniu, która stała się ikoną marki. To rozpoznawalny symbol, który jednoznacznie kojarzy się z wysoką jakością i dbałością o każdy detal.
ReplyDeleteThe price is a little steep, but you’re basically buying an art collectible you can actually wear. Totally see why people are obsessed.
ReplyDeleteThe Trapstar sweatsuit definitely has the look: clean lines, bold logo, and a design that can go from casual errands to low-key events.
ReplyDelete“Kanye’s influence on fashion never misses. The way this tee blends music culture with streetwear aesthetics is genius. Love how it represents more than just merch — it’s wearable art.”
ReplyDeleteThe Godspeed Hoodie has that perfect balance between minimalism and boldness. It’s simple but still makes you feel stylish and unique at the same time.
ReplyDeleteKapital really nailed the craftsmanship on this one. The bone detailing isn’t just printed — it’s beautifully knit into the fabric, which gives it so much depth and texture. It’s the kind of piece that feels both collectible and wearable.
ReplyDeleteThe Charles Jeffrey Loverboy tank top is seriously one of the coolest pieces I’ve picked up this season. The design is so distinctive — it’s got that punk-meets-playful vibe that makes Loverboy stand out. Definitely a conversation starter every time I wear it.
ReplyDelete“I really like how Corteiz managed to modernize the classic cargo short look. The fit is spot on — not too baggy, not too slim — and the detailing gives it that premium streetwear vibe. Worth every penny.”
ReplyDeleteWearing an Essential Hoodie feels like wrapping yourself in warmth and ease without any unnecessary weight. The cotton blend material provides a natural softness that breathes well during different seasons. It keeps you warm in the winter yet remains comfortable in spring and fall. The fit is designed to be slightly oversized which allows for layering without feeling bulky. The hood gives a sense of security and privacy when you need it. Whether you are walking through the city or sitting by a campfire the Essential Hoodie adjusts perfectly to the moment.
ReplyDeleteBig fan of the concept behind Alchemai: the brand talks about transformation, growth, making something because you want it, not because someone else already did
ReplyDeleteThe Akimbo hoodie features a bold logo on the chest. Its minimalist style makes it easy to match with any outfit. It quickly becomes a favorite in any wardrobe.
ReplyDelete