Changing the Manual acounts into Oath2 authentication

Changing the Manual acounts into Oath2 authentication

by Sara Lelli -
Number of replies: 3

Hello to all of you.

I'm using Moodle 4.1.9, and I would like to change the 16 manual accounts that we have in our online academy into accounts that uses Oath2 authentication.

I fount this page (click here) but it doesn't work anymore like that, I guess.

Can you help me? 

Thanks in advance,

Sara

Average of ratings: -
In reply to Sara Lelli

Re: Changing the Manual acounts into Oath2 authentication

by Ken Task -
Picture of Particularly helpful Moodlers

If that plugin no longer works then the only other alternative is to manually edit rows in mdl_user table with a mysql tool ... phpmyadmin?

First, however, before you do that get a look at what's there.

Query of mdl_user table below:

select id,auth,username,password from mdl_user;

You want to keep user id 1 and 2 as they are ... user id 1 is guest account and user id 2 is the original user that installed the moodle ... those should remain manual accounts.

If using Google Oauth2, moodle doesn't store passwords.

Example of Google Oauth2 account in a moodle using query above:

| 15 | oauth2 | fakeuser@gmail.com                  |                                                              |

The password column is blank in DB - does come from Google.

auth column is oauth2 and the email address is one of Googles.

Suggest backing up database first in case you have to restore.

Suggest also changing only ONE users account first and test before doing other accounts - one at a time.  16 isn't that many.

'SoS', Ken

In reply to Ken Task

Re: Changing the Manual acounts into Oath2 authentication

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
BACKUP YOUR DATABASE FIRST!!

SELECT * from mdl_user
WHERE auth LIKE "Oauth2"

should pull all your Oauth2 users - once you verify that those are the users that you need to change...


UPDATE mdl_user
SET auth = "manual"
WHERE auth LIKE "Oauth2"

BACKUP YOUR DATABASE FIRST!!
In reply to Sara Lelli

Re: Changing the Manual acounts into Oath2 authentication

by Daniel Dubbeldam -
hi Sara,

to change you 16 manual accounts to oauth2, you _could_ just update the mdl_user database with:

*UPDATE mdl_user SET auth = "oauth2" WHERE auth = "manual";*
(BACKUP THE DB FIRST!)

however:
in my experience, when you have a MANUAL account of which it has the SAME username as the linked OAUTH2 account (in example the e-mailadres), most of the times the oauth2 would log in the user's "manual" account.

IE:
i have a useraccount my@mail.com and this is a MANUAL account (of which I have a password for). This account has ID = 4.
if the oauth2 account I have also returns "my@mail.com" as username, and I login with oauth2, I get logged in with my account with ID = 4.

This way I have 2 methods to login to Moodle: Either by oauth2 of by manually typing username (email) and password...
it all depends on what you want ;)

(there is a "safety" risk: if you suspend the my@mail.com account in your oauth2 provider to prevent the user from logging in into Moodle, they still will be able to login with user/pass. So you have to suspend/delete the user in Moodle as well!