Tales from the Evil Empire

Bertrand Le Roy's blog

News


Bertrand Le Roy

BoudinFatal's Gamercard

Tales from the Evil Empire - Blogged

Blogs I read

My other stuff

Archives

April 2011 - Posts

Recovering the admin password in Orchard

(c) Bertrand Le Roy 2003These things happen, and it seems hopeless at first: you've locked yourself out of your own site and that's that. Well, not quite. If you still have access to the database there is a way out. Access may be through FTP and WebMatrix or Visual Studio if using SQL CE or through SQL Server Management Studio or whatever is your preferred way to access your database. In this tutorial I'll use WebMatrix over a local SqlCe database but other tools would work just as well with minor differences.

Open the database and go to the Orchard_Users_UserPartRecord table. You should see something like this:The user table

As you can see, the passwords are stored hashed, and the password format is specified for each user. Possible values are Hashed (the default), Encrypted and Clear.

Edit the Password column and replace the value with a temporary reset password of your choice. Then edit the PasswordFormat column and set it to Clear.Resetting the admin password

Now you should be able to log into the site using these new credentials.

You should now click on the "admin" link in order to change that password:The admin link

The reset password screenOnce your password is reset, the data in the table should be back to a hashed password:The password is back to hashed state

Many thanks to Sébastien Ros for hinting me to this trick.

Orchard 1.1: what's in it for developers?

(c) Bertrand Le Roy 2005My previous post focused on the most visible changes in Orchard 1.1 but we also made a few changes to the platform that open up new developer scenarios.

Suppressing Dependencies

Orchard is essentially built around the idea of dependency injection, but for those services that need to have a unique implementation, it was almost impossible to swap the default implementation with your own without hacking into our Autofac code.

With Orchard 1.1, you may now suppress a core dependency in order to substitute your own. Here is some code from Piotr's excellent Advanced Menu that uses that new feature:

namespace Szmyd.Orchard.Modules.Menu.Filters {
  [OrchardSuppressDependency("Orchard.UI.Navigation.MenuFilter")]
  public class MenuFilter : FilterProvider, IResultFilter {

I can't resist at this point but make this awful Mythbuster joke to convey the semantics of this:

namespace Adam.Savage {
  [OrchardSuppressDependency("YourReality")]
  public class MyOwn : IReality

Feature Priorities

One of the problems with event and handler processing in Orchard 1.0 was that the order in which multiple dependencies are registered was non-deterministic.

For example, in 1.1 we added a feature (Page Layer Hinting) that hints in a toast message whenever you create a page that you can create a widget layer for that page. The problem is that this handler needs to run after the RoutePartHandler has done its work (so we can get the right RoutePart.Path) but before Orchard.Widgets because of dependency order. This was done by giving the feature a priority of –1 in the module manifest:

Orchard.Widgets.PageLayerHinting:
        Name: Page Layer Hinting
        Description: Adds a notification after creating a new
Page with a direct link to create a Widget
Layer for that specific page by URL. Dependencies: Orchard.Widgets Category: Widget Priority: -1

WCF Services

When trying to expose an Orchard site's features as a WCF Services in 1.0, you were quickly faced with an impossible task: reconciling Orchard's constructor-based dependency injection with WCF parameterless constructors. This and other little problems.

In 1.1, you can create a SVC file using the new Orchard host factory:

<%@ ServiceHost Language="C#" Debug="true" 
    Service="MyModule.IMyService, MyAssembly"
    Factory="Orchard.Wcf.OrchardServiceHostFactory, Orchard.Framework" %>

Then register your service normally as an IDependency but with service and operation contract attributes:

using System.ServiceModel;

namespace MyModule {
    [ServiceContract]
    public interface IMyService : IDependency {
        [OperationContract]
        string GetUserEmail(string username);
    }
}

In your implementation, you can now inject your own dependencies as you would normally from an Orchard service. No need for the contract attributes on that implementation.

Many thanks to André Rodrigues for providing much of the material for this post.

What's new in Orchard 1.1?

It was only three months ago that we shipped Orchard 1.0 and 1.1 is already here with some substantial improvements and many bug fixes. Let me walk you through the most important ones…

Admin Redesign

Here is our old Orchard 1.0 dashboard next to the new one:

The Orchard 1.0 dashboardThe Orchard 1.1 dashboard

We've flattened the menu and tried to have a more rational grouping of items. Several things that used to be sub-menu items have been moved to be tabs on the right panel:A tabbed screen

Widget Management

Managing the widgets on a site in a way that scales from the simplest blogs to large sites is tricky. We implemented that with a system of programmable layers, and the UI we had to control that in 1.0 wasn't very friendly. We improved that in 1.1:Widget management

Now you can filter out inactive zones, you can toggle visibility on the layers and theme authors can now provide a visual guide of the zones they expose.

List Management

Lists are an easy way to assign custom content items to containers. The admin workflow to create and fill lists was not very intuitive in 1.0 so we improved it in 1.1. We added some help messages, some additional admin screens, and the ability to restrict a list to a specific content type.

For example, once you've added the Containable part to the Page type, you can create a list of pages:Creating a list of pages

This done, you can create new items or move existing ones to the list:List management

Notice how we now also have a new Bios admin menu item, giving us direct access to the management screen for our list.

Media Picker

It is now possible to browse for your image files right from TinyMCE:The new Media Picker

You can use the new dialog to upload new files or to browse existing ones.

Recipes

Recipes are XML files that describe series of steps such as module installation or feature activation. They can currently be used in three places: setup, module installation and import/export.

Setup recipes enable the creation of specialized distributions of Orchard. We ship with three recipes: the Default one, equivalent to our 1.0 release, the Blog recipe and the Core recipe which is limited to a very small set of features, for users who prefer to start from scratch and add stuff as they need it. You can choose the recipe to use from the setup screen:Setup recipes

Module recipes are similar but are exposed by modules and executed as part of their installation.

Import/Export

This new feature enables the import and export of site content and settings under an XML format that happens to be the same recipe format we just discussed. That opens up some interesting scenarios such as generating a setup recipe for your development environment by exporting the data from the site after it's been setup and populated.

The export screen enables you to choose exactly what data you want:The export screen

Warmup

The warmup feature creates cached versions of select pages so they can be served very fast while the rest of the site is warming up, getting compiled, etc.Configuring warmup

VS Publication

Visual Studio deployment is now configured out of the box to publish all necessary files from the web project into production.

URL Alternates

This feature adds shape alternates based on the current URL. For example, layout-url-about.cshtml or Widget-HtmlWidget-url-homepage.cshtml are alternate template names for respectively the ~/about page and the home page.

Shape Tracing

I kept my favorite feature for the end of this post. You can think of Shape Tracing as Firebug for Orchard.Shape Tracing

Once enabled and activated on a page of your site, Shape Tracing enables you to visually explore the tree of shapes that was used to compose it.

The first tab shows the shape name, the template that was used to render it, the display type (Detail, Summary, etc.) and the possible alternates. It even exposes buttons to create these alternate files if you want to.

The Model tab is extremely useful in building a template: it enables you to explore the shape object and drill into it. When you click one of the nodes in the tree, the top line of the tab shows the expression that you can copy and paste into your template in order to render it.Shape Tracing: the Model tab

The Placement tab shows the placement.info file that determined the placement of the shape.The Placement tab

The Template and HTML tabs show the server code for the shape and the corresponding rendered HTML.The Template tabThe HTML tab

Bug fixes

And this is pretty much it, except for dozens of bug fixes.

The release can be downloaded from CodePlex:
http://orchard.codeplex.com/releases/view/59918

Upgrade instructions from 1.0 to 1.1:
http://orchardproject.net/docs/Upgrading-a-site-to-a-new-version-of-Orchard.ashx

Deploying an Orchard site using WebMatrix

In this screencast, I'm publishing an Orchard web site and its SQL Express database to a shared host using WebMatrix.

Migrating an Orchard site from SqlCe to Sql Express using WebMatrix

In this short video, I show how to use WebMatrix to migrate an Orchard site from using the file-based SqlCe to a SQL Express database.

More Posts