Skip to content

Add option to replace default flarum login in header with FoF Passport #9

@vlntsolo

Description

@vlntsolo

One of the applications of this extension might be external user management system for one or more Flarum instances. In this case one might need to hide default Flarum user management modals and restrict authentication to OAuth server only.

It might be handy to have additional boolean setting in extension admin area for this flow.

Front-end forum/index.js can have additional block:

import HeaderSecondary from "flarum/components/HeaderSecondary";
import SettingsPage from "flarum/components/SettingsPage";

app.initializers.add('fof-passport', () => {
 //....
 //Removes Flarum default header signUp logIn links and ads OAuth button
 extend(HeaderSecondary.prototype, 'items', function(items) {
  //If user isn't logged in displays FoF Passport LogIn button
  if (!app.session.user) {
    items.add('fof-passport', LogInButton.component({
        className: 'Button LogInButton--passport',
        icon: app.forum.attribute('fof-passport.loginIcon'),
        path: '/auth/passport',
        children: app.forum.attribute('fof-passport.loginTitle'),
    }));
  }
//Remove Login and signUp buttons
    items.remove("logIn");
    items.remove("signUp");
 });
 //Remove account details change buttons from profile
 extend(SettingsPage.prototype, 'accountItems', function(items) {
   items.remove('changeEmail');
   items.remove('changePassword');
 });

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions