It seems like what you're looking for is SSO with salesforce as both the SP and IP. I've never tried it within the same org however. Here is some info that you can try to use:
Salesforce to Salesforce SSO
SSO in communities
In theory, you set up SSO, Then you enable your community to use SSO pointing to Salesforce as the IP, then you create a login flow ...